js排查pages和api

注:这个只是为了学习原理,更好的工具推荐是F6JO大佬的bp插件JsRouteScan

或者自己访问所有链接把所有js保存到同一目录,再用正则表达式提取比较全面

原理

通过伪造请求头,遍历所有的src跳转链接,保存所有响应为200的js放在同一目录下,用脚本遍历js,过滤出正则表达式对应的前端目录,拼接目录进行如上循环,直到连续两次路径集合相同或达到最大迭代次数,最后对js目录提取规定的正则表达式

不足:

仅仅对url的目录排查和哈希路由排查,后续能力提升可能会功能进行增强

正则表达式

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
pattern_groups = {
"PagePath Matches": [
(re.compile(r'pagePath:\s*"(.*?)"'), "pagePath_double_quotes"),
(re.compile(r"pagePath:\s*'(.*?)'"), "pagePath_double_quotes"),
],
"Path Matches": [
(re.compile(r'path:\s*"(.*?)"'), "path_double_quotes"),
(re.compile(r"path:\s*'(.*?)'"), "path_double_quotes"),
(re.compile(r'url:\s*"([^"]+)"'), "path_double_quotes"),
(re.compile(r'url: "([^"]+)'), "path_double_quotes"),
],
"GET Matches": [
(re.compile(r'get\([^()]*?"([^"]*?)"[^()]*?\)'), "get_double_quotes"),
(re.compile(r"get\([^()]*?['\"]([^'\"]*?)['\"][^()]*?\)"), "get_double_quotes"),
],
"POST Matches": [
(re.compile(r'post\([^()]*?"([^"]*?)"[^()]*?\)'), "post_double_quotes"),
(re.compile(r"POST\([^()]*?['\"]([^'\"]*?)['\"][^()]*?\)"), "post_double_quotes"),
]
}