Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2021-1-capstone-design2
/
2017103967
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
김성주
2021-06-14 06:07:03 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
45fcec6a051d4e2a7eb0d798cfd9b8605df3f055
45fcec6a
1 parent
cb318f7f
fixed some comments
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
4 additions
and
14 deletions
code/dataset_generator/data_obfuscator.py
code/dataset_generator/data_obfuscator_v2.py
code/dataset_generator/file_parser.py
code/dataset_generator/data_obfuscator.py
View file @
45fcec6
...
...
@@ -40,7 +40,6 @@ def detect_vars(line): # detect variables and return range tuples. except for ke
def
obfuscate
(
lines
,
vars
,
dictionary
,
mapper
):
# obfuscate the code
ret
=
list
()
### write_file('D:/Develop/ori.py', lines)
for
line
in
lines
:
var_ranges
=
detect_vars
(
line
)
...
...
@@ -64,7 +63,6 @@ def obfuscate(lines, vars, dictionary, mapper): # obfuscate the code
ret
.
append
(
new_line
)
### write_file('D:/Develop/obf.py', ret)
return
ret
def
create_var_histogram
(
input
,
outPath
):
...
...
@@ -122,8 +120,6 @@ def obfuscate_files(input, output, var=None, threshold=4000): # obfuscate variab
dictionary
=
create_dictionary
(
var
)
mapper
=
create_mapper
(
len
(
var
))
### obfuscate(codes[0][1], var, dictionary, mapper)
for
path
,
code
in
codes
:
obfuscated
=
obfuscate
(
code
,
var
,
dictionary
,
mapper
)
...
...
code/dataset_generator/data_obfuscator_v2.py
View file @
45fcec6
...
...
@@ -2,7 +2,7 @@ from utils import *
import
file_parser
import
re
# obfuscator v2 generate random name for methods
# obfuscator v2 generate
s
random name for methods
def
random_character
(
start
=
False
):
if
start
:
...
...
@@ -75,7 +75,6 @@ def detect_vars(line): # detect variables and return range tuples. except for ke
def
obfuscate
(
lines
,
vars
,
dictionary
,
mapper
):
# obfuscate the code
ret
=
list
()
### write_file('D:/Develop/ori.py', lines)
for
line
in
lines
:
var_ranges
=
detect_vars
(
line
)
...
...
@@ -99,7 +98,6 @@ def obfuscate(lines, vars, dictionary, mapper): # obfuscate the code
ret
.
append
(
new_line
)
### write_file('D:/Develop/obf.py', ret)
return
ret
def
create_var_histogram
(
input
,
outPath
):
...
...
@@ -157,8 +155,6 @@ def obfuscate_files(input, output, var=None, threshold=4000): # obfuscate variab
dictionary
=
create_dictionary
(
var
)
mapper
=
create_mapper_v2
(
len
(
var
))
### obfuscate(codes[0][1], var, dictionary, mapper)
for
path
,
code
in
codes
:
obfuscated
=
obfuscate
(
code
,
var
,
dictionary
,
mapper
)
...
...
code/dataset_generator/file_parser.py
View file @
45fcec6
...
...
@@ -2,10 +2,6 @@ from utils import *
import
re
import
keyword
'''
Test multi-line comments
'''
LIBRARYS
=
list
()
def
parse_keywords
(
line
,
out
):
# out : output dictionary to sum up frequencies
...
...
@@ -26,7 +22,7 @@ def parse_keywords(line, out): # out : output dictionary to sum up frequencies
if
not
key
or
is_number
(
key
)
or
key
[
0
]
in
"0123456789"
:
continue
## Exception code here
## Exception code here
if you want
if
key
in
[
'from'
,
'import'
]:
import_line
=
True
...
...
@@ -56,6 +52,8 @@ def parse_block(lines): # parse to import / def / class / normal (if, for, etc)
block_stack
=
[
root
]
i
=
0
L
=
len
(
lines
)
### commented because of some exceptions
# par_stack = list()
# multi_string_stack = list()
...
...
Please
register
or
login
to post a comment