-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathParamx.jl
101 lines (88 loc) · 2.5 KB
/
Paramx.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
include("src/package.jl")
include("src/arg.jl")
include("src/func.jl")
# user passed cli arguments
const args = ARGUMENTS()
const PROCESSORS = Dict(
"html" => (source) -> begin
args["a"] && extract_a_tags(source)
args["i"] && extract_input_tags(source)
args["s"] && extract_script_tags(source)
end,
"js" => (source) -> begin
source = "<body>\n<script>\n" * source * "\n</script>\n</body>"
args["p"] && extract_script_tags(source)
end,
"php" => (source) -> args["p"] && extract_php_params(source),
"xml" => (source) -> args["p"] && extract_xml_elemnts(source),
"req" => (source) -> begin
args["p"] && (extract_script_tags(source); extract_input_tags(source))
end,
"resp" => (source) -> begin
args["p"] && (extract_script_tags(source); extract_input_tags(source))
end,
)
function processSource(source::String, filetype::String)
if haskey(PROCESSORS, filetype)
PROCESSORS[filetype](source)
else
@warn "Unknown filetype: $filetype"
end
args["w"] && extract_url(source)
args["f"] && extract_file_name(source, args["e"])
end
function parseSource()
!isempty(args["u"]) && return SendHttpRequest(args["u"])
!isempty(args["html"]) && return ReadFile(args["html"])
!isempty(args["js"]) && return ReadFile(args["js"])
!isempty(args["php"]) && return ReadFile(args["php"])
!isempty(args["xml"]) && return ReadFile(args["xml"])
!isempty(args["req"]) && return ReadFile(args["req"])
!isempty(args["resp"]) && return ReadFile(args["resp"])
end
function main()
if !isempty(args["ul"])
Threads.@threads for url in readlines(args["ul"])
try
source = SendHttpRequest(url)
processSource(source, args["ft"])
catch e
msg = styled"""Error processing URL: {error:$(file)}\n{bright_blue:$(url)} -> 💢 {error:dropped}"""
@error msg
continue
end
end
@goto resume
end
source = parseSource()
processSource(source, args["ft"])
@label resume
Data = union(
EXTRACTED_JS_VARIABLES,
EXTRACTED_JS_OBJECTS,
EXTRACTED_JS_FUNC_ARGS,
EXTRACTED_INPUT_TEXTAREA_ID_NAME,
EXTRACTED_URLS_OR_PATHS,
EXTRACTED_QUERY_KEYS,
EXTRACTED_PHP_VARIABLES,
EXTRACTED_PHP_GET_POST,
EXTRACTED_XML_ELEMENTS,
EXTRACTED_FILE_NAMES,
)
if args["c"]
CountItems(false)
exit(0)
elseif args["cn"]
CountItems(true)
exit(0)
end
if !isempty(args["o"])
WriteFile(args["o"], "w+", join(Data, "\n"))
@info "\033[33m$(length(Data))\033[0m Items Found"
@info "data saved in file: $(args["o"])"
else
print(join(Data, "\n"), "\n")
@info "\033[33m$(length(Data))\033[0m Items Found"
end
end
main()