Toggle navigation
Toggle navigation
This project
Loading...
Sign in
노현종
/
2018-1-Capstone1-VulnNotti
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
노현종
2018-05-23 00:56:19 +0900
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
4b7e2f371650dbf5e1f5ea67a6b9ce3f285c74d1
4b7e2f37
2 parents
a417248e
c6a2bab8
Merge branch 'master' into master3
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
190 additions
and
91 deletions
VulnNotti/templates/registration/logged_out.html
Vulnerablity_DB/VulnCrawler/VulnAbstractCrawler.cs
Vulnerablity_DB/VulnCrawler/VulnC.cs
_config.yml
VulnNotti/templates/registration/logged_out.html
deleted
100644 → 0
View file @
a417248
File mode changed
Vulnerablity_DB/VulnCrawler/VulnAbstractCrawler.cs
View file @
4b7e2f3
...
...
@@ -382,11 +382,18 @@ namespace VulnCrawler
{
return
false
;
}
/* 대문자로 구성된 변수면 넘어감 */
if
(
m
.
Value
.
All
(
c
=>
char
.
IsUpper
(
c
)
||
!
char
.
IsLetter
(
c
)))
{
return
false
;
}
/* 제일 앞자리가 숫자로 시작하면 넘어감 */
if
(
Regex
.
IsMatch
(
m
.
Value
,
invalidPattern
))
{
return
false
;
}
/* 전 단계에서 구한 메서드 목록에 있으면 넘어감 */
if
(
methodSets
.
Contains
(
m
.
Value
))
{
...
...
@@ -403,6 +410,8 @@ namespace VulnCrawler
{
return
false
;
}
return
true
;
})
.
Distinct
(
new
MatchComparer
());
...
...
Vulnerablity_DB/VulnCrawler/VulnC.cs
View file @
4b7e2f3
...
...
@@ -232,7 +232,6 @@ namespace VulnCrawler
// srcCode = Regex.Replace(srcCode, @"if.+\n\{", @"if.+\{", RegexOptions.Multiline);
var
split
=
srcCode
.
Split
(
'\n'
);
int
bracketCount
=
0
;
var
blockList
=
new
List
<
Block
>();
StringBuilder
builder
=
new
StringBuilder
();
var
crList
=
criticalList
as
HashSet
<
string
>;
...
...
@@ -240,121 +239,211 @@ namespace VulnCrawler
{
return
null
;
}
bool
hasIf
=
false
;
bool
mainLine
=
true
;
/* 현재 라인이 메인 코드 라인인지 */
bool
criticalBlock
=
false
;
/* 현재 라인이 크리티컬 블록 라인인지 */
int
blockNum
=
1
;
/* 블록 번호 */
var
mainQ
=
new
Queue
<
string
>();
var
groupQ
=
new
Queue
<
string
>();
bool
mainLine
=
true
;
int
crNum
=
1
;
int
bracketCount
=
1
;
bool
prevStartBlock
=
false
;
foreach
(
var
line
in
split
)
{
bool
hasRight
=
false
;
string
trim
=
line
.
Trim
();
/* 중괄호 수 세기 */
int
openBracketCount
=
trim
.
Count
(
c
=>
c
==
'{'
);
int
closeBracketCount
=
trim
.
Count
(
c
=>
c
==
'}'
);
//if (!hasIf)
//{
// if (Regex.IsMatch(trim, @"^if.+\)$"))
// {
// // Console.WriteLine("if 들어감");
// hasIf = true;
// }
//}
//else
//{
// if (!Regex.IsMatch(trim, @"^\{"))
// {
// openBracketCount++;
// }
// hasIf = false;
//}
int
subtract
=
openBracketCount
-
closeBracketCount
;
bracketCount
+=
subtract
;
if
(
trim
.
Equals
(
"}"
))
bool
criticalBlock
=
false
;
string
trimLine
=
line
.
Trim
();
if
(
mainLine
)
{
builder
.
AppendLine
(
line
);
hasRight
=
true
;
if
(
trimLine
.
EndsWith
(
"&&"
)
||
trimLine
.
EndsWith
(
"||"
))
{
mainQ
.
Enqueue
(
line
);
continue
;
}
if
(
trimLine
.
StartsWith
(
"&&"
)
||
trimLine
.
StartsWith
(
"||"
))
{
groupQ
.
Enqueue
(
line
);
continue
;
}
bracketCount
=
1
;
StringBuilder
groupBuilder
=
new
StringBuilder
();
while
(
groupQ
.
Count
>
0
)
{
string
s
=
groupQ
.
Dequeue
();
if
(!
criticalBlock
)
{
foreach
(
var
item
in
ExtractCriticalVariant
(
s
))
{
if
(
crList
.
Contains
(
item
))
{
criticalBlock
=
true
;
break
;
}
}
}
groupBuilder
.
AppendLine
(
s
);
}
if
(
groupBuilder
.
Length
>
0
)
{
blockList
.
Add
(
new
Block
{
Code
=
groupBuilder
.
ToString
(),
HasCritical
=
criticalBlock
,
Num
=
crNum
++});
}
if
(
Regex
.
IsMatch
(
trimLine
,
@"(if|for|while|switch|do)\s*"
))
{
if
(!
trimLine
.
EndsWith
(
"{"
))
{
mainLine
=
false
;
prevStartBlock
=
true
;
}
else
if
(
trimLine
.
EndsWith
(
";"
))
{
mainLine
=
true
;
}
else
{
mainLine
=
false
;
bracketCount
++;
}
groupQ
.
Enqueue
(
line
);
continue
;
}
mainQ
.
Enqueue
(
line
);
}
/* 중괄호 연산 결과 1이라는 것은 메인 라인 */
if
(
bracketCount
==
1
)
else
{
/*
* 깊이가 1인데 mainLine이
* false 이면 넘어왔다는 것이니 현재까지 코드
* blockList에 추가
*/
if
(!
mainLine
)
/* 중괄호 수 세기 */
int
openBracketCount
=
trimLine
.
Count
(
c
=>
c
==
'{'
);
int
closeBracketCount
=
trimLine
.
Count
(
c
=>
c
==
'}'
);
int
subtract
=
openBracketCount
-
closeBracketCount
;
bracketCount
+=
subtract
;
if
(
trimLine
.
EndsWith
(
"&&"
)
||
trimLine
.
EndsWith
(
"||"
))
{
groupQ
.
Enqueue
(
line
);
continue
;
}
//if (trimLine.StartsWith("&&") || trimLine.StartsWith("||"))
//{
// mainQ.Enqueue(line);
// continue;
//}
groupQ
.
Enqueue
(
line
);
if
(
prevStartBlock
)
{
prevStartBlock
=
false
;
if
(
Regex
.
IsMatch
(
trimLine
,
@"(if|for|while|switch|do)\s*\("
))
{
prevStartBlock
=
true
;
continue
;
}
else
if
(
trimLine
.
EndsWith
(
";"
))
{
bracketCount
--;
}
}
if
(
bracketCount
<=
1
)
{
if
(
trimLine
.
Contains
(
"else"
))
{
bracketCount
++;
prevStartBlock
=
true
;
continue
;
}
mainLine
=
true
;
}
StringBuilder
mainBuilder
=
new
StringBuilder
();
while
(
mainQ
.
Count
>
0
)
{
string
s
=
builder
.
ToString
();
if
(!
string
.
IsNullOrWhiteSpace
(
s
)
)
string
s
=
mainQ
.
Dequeue
();
if
(!
criticalBlock
)
{
blockList
.
Add
(
new
Block
()
{
HasCritical
=
criticalBlock
,
Code
=
s
,
Num
=
blockNum
});
blockNum
++;
criticalBlock
=
false
;
builder
.
Clear
();
foreach
(
var
item
in
ExtractCriticalVariant
(
s
))
{
if
(
crList
.
Contains
(
item
))
{
criticalBlock
=
true
;
break
;
}
}
}
mainBuilder
.
AppendLine
(
s
);
}
if
(
mainBuilder
.
Length
>
0
)
{
blockList
.
Add
(
new
Block
{
Code
=
mainBuilder
.
ToString
(),
HasCritical
=
criticalBlock
,
Num
=
crNum
++
});
}
mainLine
=
true
;
}
/* 2 이상이라는 건 메인 라인 X */
else
if
(
bracketCount
>=
2
)
}
bool
cb
=
false
;
if
(
mainQ
.
Count
>
0
)
{
StringBuilder
mainBuilder
=
new
StringBuilder
();
while
(
mainQ
.
Count
>
0
)
{
/*
* 깊이가 2 이상인데 mainLine이
* true면 넘어왔다는 것이니 현재까지 코드
* blockList에 추가
*/
if
(
mainLine
)
string
s
=
mainQ
.
Dequeue
();
if
(!
cb
)
{
string
s
=
builder
.
ToString
();
if
(!
string
.
IsNullOrWhiteSpace
(
s
))
foreach
(
var
item
in
ExtractCriticalVariant
(
s
))
{
blockList
.
Add
(
new
Block
()
{
HasCritical
=
criticalBlock
,
Code
=
s
,
Num
=
blockNum
});
blockNum
++;
criticalBlock
=
false
;
builder
.
Clear
();
if
(
crList
.
Contains
(
item
))
{
cb
=
true
;
break
;
}
}
}
main
Line
=
false
;
main
Builder
.
AppendLine
(
s
)
;
}
/* 이도 저도 아니면 그냥 넘어감 */
else
if
(
mainBuilder
.
Length
>
0
)
{
continue
;
blockList
.
Add
(
new
Block
{
Code
=
mainBuilder
.
ToString
(),
HasCritical
=
cb
,
Num
=
crNum
++
})
;
}
/* 현재 코드 라인에서 변수 추출시켜서 크리티컬 리스트와 대조 */
foreach
(
var
var
in
ExtractCriticalVariant
(
line
))
}
else
{
StringBuilder
groupBuilder
=
new
StringBuilder
();
while
(
groupQ
.
Count
>
0
)
{
/* 크리티컬 리스트에 추출한 변수가 들어있다면 추가 */
if
(
criticalList
.
Contains
(
var
)
)
string
s
=
groupQ
.
Dequeue
();
if
(
!
cb
)
{
criticalBlock
=
true
;
break
;
foreach
(
var
item
in
ExtractCriticalVariant
(
s
))
{
if
(
crList
.
Contains
(
item
))
{
cb
=
true
;
break
;
}
}
}
groupBuilder
.
AppendLine
(
s
);
}
if
(
!
hasRight
)
if
(
groupBuilder
.
Length
>
0
)
{
builder
.
AppendLine
(
line
);
blockList
.
Add
(
new
Block
{
Code
=
groupBuilder
.
ToString
(),
HasCritical
=
cb
,
Num
=
crNum
++
});
}
}
/* 마지막 남은게 있을 수 있으니 추가 */
string
fs
=
builder
.
ToString
();
if
(!
string
.
IsNullOrWhiteSpace
(
fs
))
{
blockList
.
Add
(
new
Block
()
{
HasCritical
=
criticalBlock
,
Code
=
fs
,
Num
=
blockNum
});
blockNum
++;
criticalBlock
=
false
;
builder
.
Clear
();
}
return
blockList
;
...
...
_config.yml
0 → 100644
View file @
4b7e2f3
theme
:
jekyll-theme-midnight
\ No newline at end of file
Please
register
or
login
to post a comment