-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chg: [improvement] format output + typo const
- Loading branch information
1 parent
5819c70
commit dc4209d
Showing
12 changed files
with
70 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import yaml | ||
|
||
from format.yara import formatYara | ||
from format.regex import formatRegex, formatRegexRetrie | ||
from format.yaml import formatYaml | ||
|
||
def formatOutput(format, resultList, domain, pathOutput, givevariations=False, betterRegex=False): | ||
""" | ||
Call different function to create the right format file | ||
""" | ||
|
||
if format == "text": | ||
if pathOutput and not pathOutput == "-": | ||
with open(f"{pathOutput}/{domain}.txt", "w", encoding='utf-8') as write_file: | ||
for element in resultList: | ||
if givevariations: | ||
write_file.write(f"{element[0]}, {element[1]}\n") | ||
else: | ||
write_file.write(element + "\n") | ||
elif pathOutput == "-": | ||
for element in resultList: | ||
if givevariations: | ||
print(f"{element[0]}, {element[1]}") | ||
else: | ||
print(element) | ||
|
||
elif format == "yara": | ||
yara = formatYara(resultList, domain, givevariations) | ||
if pathOutput and not pathOutput == "-": | ||
with open(f"{pathOutput}/{domain}.yar", "w", encoding='utf-8') as write_file: | ||
write_file.write(yara) | ||
elif pathOutput == "-": | ||
print(yara) | ||
|
||
elif format == "regex": | ||
if betterRegex: | ||
regex = formatRegexRetrie(resultList, givevariations) | ||
else: | ||
regex = formatRegex(resultList, givevariations) | ||
if pathOutput and not pathOutput == "-": | ||
with open(f"{pathOutput}/{domain}.regex", "w", encoding='utf-8') as write_file: | ||
write_file.write(regex) | ||
elif pathOutput == "-": | ||
print(regex) | ||
|
||
elif format == "yaml": | ||
yaml_file = formatYaml(resultList, domain, givevariations) | ||
if pathOutput and not pathOutput == "-": | ||
with open(f"{pathOutput}/{domain}.yml", "w", encoding='utf-8') as write_file: | ||
yaml.dump(yaml_file, write_file) | ||
elif pathOutput == "-": | ||
print(yaml_file) | ||
else: | ||
print(f"Unknown format: {format}. Will use text format instead") | ||
formatOutput("text", resultList, domain, pathOutput, givevariations) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
# Import all the utils | ||
from .utils.generator_functions import * | ||
|
||
|
||
""" | ||
Original Domain Typosquatted Domain | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
# Import all the utils | ||
from .utils.generator_functions import * | ||
|
||
|
||
""" | ||
Original Domain Typosquatted Domain | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters