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-24 00:33:07 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
7e5ebad0fd7e355cbe7b3f2316619103980fc8b2
7e5ebad0
1 parent
2729bb2e
추상화 정규화 추가
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
78 additions
and
11 deletions
Vulnerablity_DB/VulnCrawler/Program.cs
Vulnerablity_DB/VulnCrawler/VulnAbstractCrawler.cs
Vulnerablity_DB/VulnCrawler/VulnC.cs
Vulnerablity_DB/VulnCrawler/VulnPython.cs
Vulnerablity_DB/VulnCrawler/VulnWorker.cs
Vulnerablity_DB/VulnCrawler/Program.cs
View file @
7e5ebad
...
...
@@ -66,7 +66,7 @@ namespace VulnCrawler
}
public
static
void
Run
()
{
// Repository 폴더들이 있는 주소를 지정하면 하위 폴더 목록을 가져옴(Repository 목록)
Regex
.
CacheSize
=
50
;
// var fields = VulnWorker.GetCriticalVariant(@"return _is_safe_url(url, host) and _is_safe_url(url.replace('\\', '/'), host)");
var
c
=
new
VulnC
();
...
...
Vulnerablity_DB/VulnCrawler/VulnAbstractCrawler.cs
View file @
7e5ebad
This diff is collapsed. Click to expand it.
Vulnerablity_DB/VulnCrawler/VulnC.cs
View file @
7e5ebad
...
...
@@ -359,7 +359,6 @@ namespace VulnCrawler
{
continue
;
}
if
(!(
trimLine
.
EndsWith
(
"}"
)
||
trimLine
.
EndsWith
(
";"
)))
{
continue
;
...
...
@@ -370,7 +369,6 @@ namespace VulnCrawler
prevStartBlock
=
true
;
continue
;
}
mainLine
=
true
;
}
...
...
@@ -398,11 +396,7 @@ namespace VulnCrawler
{
blockList
.
Add
(
new
Block
{
Code
=
mains
,
HasCritical
=
criticalBlock
,
Num
=
crNum
++
});
}
}
}
bool
cb
=
false
;
...
...
@@ -459,5 +453,75 @@ namespace VulnCrawler
return
blockList
;
}
public
override
string
Abstract
(
string
blockCode
,
IDictionary
<
string
,
string
>
dict
,
IDictionary
<
string
,
string
>
methodDict
)
{
var
split
=
blockCode
.
Split
(
'\n'
);
var
varName
=
"VAL"
;
var
methodName
=
"FUNC"
;
int
varIdx
=
dict
.
Count
();
int
methodIdx
=
methodDict
.
Count
();
var
removes
=
Regex
.
Split
(
blockCode
,
Environment
.
NewLine
,
RegexOptions
.
Multiline
);
StringBuilder
builder
=
new
StringBuilder
();
Console
.
ForegroundColor
=
ConsoleColor
.
DarkYellow
;
foreach
(
var
item
in
removes
)
{
if
(
string
.
IsNullOrWhiteSpace
(
item
))
{
continue
;
}
Console
.
Write
(
item
);
builder
.
Append
(
item
);
// Console.ReadLine();
}
// Console.WriteLine(builder.ToString());
Console
.
ResetColor
();
foreach
(
var
line
in
split
)
{
var
varList
=
ExtractMethodVariantList
(
line
,
skipDefine
:
false
);
if
(
varList
==
null
)
{
continue
;
}
foreach
(
var
var
in
varList
.
Vars
)
{
if
(!
dict
.
ContainsKey
(
var
))
{
dict
[
var
]
=
varName
+
varIdx
++;
}
}
foreach
(
var
m
in
varList
.
Methods
)
{
if
(!
methodDict
.
ContainsKey
(
m
))
{
methodDict
[
m
]
=
methodName
+
methodIdx
++;
}
}
}
var
sortVarDict
=
dict
.
OrderByDescending
(
p
=>
p
.
Key
).
ToDictionary
(
p
=>
p
.
Key
,
p
=>
p
.
Value
);
var
sortMethodDict
=
methodDict
.
OrderByDescending
(
p
=>
p
.
Key
).
ToDictionary
(
p
=>
p
.
Key
,
p
=>
p
.
Value
);
string
temp
=
blockCode
;
foreach
(
var
pair
in
sortVarDict
)
{
temp
=
Regex
.
Replace
(
temp
,
$
@"\b{pair.Key}\b"
,
pair
.
Value
);
}
foreach
(
var
pair
in
sortMethodDict
)
{
temp
=
Regex
.
Replace
(
temp
,
$
@"\b{pair.Key}\b"
,
pair
.
Value
);
}
temp
=
Regex
.
Replace
(
temp
,
@"\s"
,
""
,
RegexOptions
.
Multiline
);
temp
=
Regex
.
Replace
(
temp
,
@"{|}|;|\)|\("
,
""
);
temp
=
temp
.
ToUpper
();
return
temp
;
}
}
}
...
...
Vulnerablity_DB/VulnCrawler/VulnPython.cs
View file @
7e5ebad
...
...
@@ -75,5 +75,10 @@ namespace VulnCrawler
{
throw
new
NotImplementedException
();
}
public
override
string
Abstract
(
string
blockCode
,
IDictionary
<
string
,
string
>
dict
,
IDictionary
<
string
,
string
>
methodDict
)
{
throw
new
NotImplementedException
();
}
}
}
...
...
Vulnerablity_DB/VulnCrawler/VulnWorker.cs
View file @
7e5ebad
...
...
@@ -41,16 +41,13 @@ namespace VulnCrawler
private
static
void
PrintPatchEntrys
(
IEnumerable
<
PatchEntryChanges
>
entrys
,
VulnAbstractCrawler
self
,
string
commitMsg
,
string
cve
)
{
foreach
(
var
entry
in
entrys
)
{
// 기존 소스코드
var
oldOid
=
entry
.
OldOid
;
try
{
Blob
oldBlob
=
self
.
Repository
.
Lookup
<
Blob
>(
oldOid
);
string
oldContent
=
oldBlob
.
GetContentText
();
// 변경된 소스코드
var
newOid
=
entry
.
Oid
;
Blob
newBlob
=
self
.
Repository
.
Lookup
<
Blob
>(
newOid
);
...
...
@@ -116,6 +113,7 @@ namespace VulnCrawler
Console
.
WriteLine
(
$
"=====block({block.Num}, {block.HasCritical.ToString()})"
);
Console
.
WriteLine
(
block
.
Code
);
Console
.
ResetColor
();
Console
.
WriteLine
(
$
"AbsCode = \n{block.AbsCode}"
);
Console
.
WriteLine
(
$
"MD5 = {block.Hash}"
);
}
...
...
@@ -178,7 +176,7 @@ namespace VulnCrawler
catch
(
Exception
e
)
{
// Console.WriteLine(entry.Patch);
//
Console.WriteLine(e.ToString());
//
Console.WriteLine(e.ToString());
// Console.ReadLine();
continue
;
}
...
...
Please
register
or
login
to post a comment