forked from lcatro/browser_vuln_check
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbase_function.py
More file actions
57 lines (39 loc) · 1.61 KB
/
Copy pathbase_function.py
File metadata and controls
57 lines (39 loc) · 1.61 KB
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
import os
import sys
def resolve_url_parameter(url,url_parameter_name) : # Just Resolve First URL Parameter
url_flag='?'+url_parameter_name+'='
url_flag_index=url.find(url_flag)
return url[url_flag_index+len(url_flag):]
def get_relative_path(is_crash_path,file_path) :
current_file_path=get_current_path()
if is_crash_path :
return file_path.replace(current_file_path+'crash_poc\\','')
return file_path.replace(current_file_path+'uncrash_poc\\','')
def get_current_path() : # Get Script Save Path
current_file_name=sys.argv[0]
current_path=current_file_name[:current_file_name.rfind('\\')+1]
return current_path
def list_dir_file(file_path) : # Get All File and Dir Name at file_path
output_file_list=[]
for dir_path,dir_name,file_name in os.walk(file_path) :
for file_name_index in file_name :
output_file_list.append((dir_path+'\\'+file_name_index,file_name_index))
return output_file_list
def read_poc(is_crash_poc,poc_name) : # Read a PoC File from uncrash/crash PoC dir
poc_file_list=[]
poc_file_data=''
if is_crash_poc :
poc_file_list=list_dir_file('crash_poc')
else :
poc_file_list=list_dir_file('uncrash_poc')
for poc_file_index in poc_file_list :
if poc_file_index[1]==poc_name :
return read_file(poc_file_index[0])
return ''
def read_file(file_path) :
poc_file=open(file_path)
poc_file_data=''
if poc_file :
poc_file_data=poc_file.read()
poc_file.close()
return poc_file_data