├── onetips ├── readme.md └── heavy-query-sqli.md ├── bypass-XPO ├── readme.md ├── xpo.php ├── iframe_src_future.php └── poc.html ├── request_merging ├── iframe.html ├── img0.png ├── img1.png ├── iframe_merging_poc.html ├── index.html ├── many_out_script.html ├── response_with_diff_size.py ├── jsonp.php ├── poc.html ├── fuzz_size_of_response.html ├── iframe_request_merging.html ├── readme.md └── readme.bak.md.txt ├── fuzzing-Chrome-XSS-Auditor-by-HTTP-status-code ├── test.html ├── xss.php ├── location_to_another.php ├── fuzzfile │ ├── 200.php │ ├── 201.php │ ├── 202.php │ ├── 203.php │ ├── 204.php │ ├── 205.php │ ├── 206.php │ ├── 207.php │ ├── 208.php │ ├── 226.php │ ├── 300.php │ ├── 301.php │ ├── 302.php │ ├── 303.php │ ├── 304.php │ ├── 305.php │ ├── 306.php │ ├── 307.php │ └── 308.php ├── status_code_in_phpself.php ├── generate_phpfile.py ├── test_chrome_xss_adult.html ├── test_chrome_js_outside_execute.html └── readme.md ├── fuzzing-browser-MIME-Sniffing-by-status-code-in-HTTP1.0 ├── firefox.png ├── http_status_code_in_query.php ├── readme.md └── fuzz.html ├── python-url-object-for-uniq ├── readme.md └── url_filter.py ├── fuzzing_char_after_angel_bracket ├── readme.md ├── fuzz.html └── main.py ├── .gitattributes ├── golang_https_http_server_conflict ├── cert.pem ├── create_file │ └── create_file.go ├── private.pem └── app.go ├── readme.md ├── postMessage_and_addEventListener_message ├── postmessage.html └── topwindow.html ├── golang-use-struct-inheritance-and-bson-together.md ├── create_readme.py ├── .gitignore └── xunfeng_icmp_scan_test.py /onetips/readme.md: -------------------------------------------------------------------------------- 1 | # 把 漏洞 或者 Writeup 拆开成一个个知识点 2 | 3 | 使得信息更加简洁。 4 | -------------------------------------------------------------------------------- /bypass-XPO/readme.md: -------------------------------------------------------------------------------- 1 | # bypass X-Frame-Options: SAMEORIGIN 2 | 3 | 4 | -------------------------------------------------------------------------------- /request_merging/iframe.html: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /request_merging/img0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/neargle/tips-note/HEAD/request_merging/img0.png -------------------------------------------------------------------------------- /request_merging/img1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/neargle/tips-note/HEAD/request_merging/img1.png -------------------------------------------------------------------------------- /bypass-XPO/xpo.php: -------------------------------------------------------------------------------- 1 | "); 6 | -------------------------------------------------------------------------------- /fuzzing-Chrome-XSS-Auditor-by-HTTP-status-code/test.html: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /fuzzing-Chrome-XSS-Auditor-by-HTTP-status-code/xss.php: -------------------------------------------------------------------------------- 1 | "; 4 | echo "$payload"; 5 | echo ""; -------------------------------------------------------------------------------- /fuzzing-Chrome-XSS-Auditor-by-HTTP-status-code/location_to_another.php: -------------------------------------------------------------------------------- 1 | `, Fuzz更多的属性和方法才可以获得想要的bypass tip。 8 | 9 | but it is another story... 10 | -------------------------------------------------------------------------------- /request_merging/iframe_merging_poc.html: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /fuzzing-Chrome-XSS-Auditor-by-HTTP-status-code/status_code_in_phpself.php: -------------------------------------------------------------------------------- 1 | 7 | 8 | 444444 9 | -------------------------------------------------------------------------------- /request_merging/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | index in http://0.0.0.0 5 | 6 | 7 | 8 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /bypass-XPO/poc.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | poc localhost:8082 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /request_merging/many_out_script.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /request_merging/response_with_diff_size.py: -------------------------------------------------------------------------------- 1 | from flask import Response, Flask, stream_with_context 2 | 3 | app = Flask(__name__) 4 | 5 | @app.route('/jsonp/') 6 | def jsonp(size): 7 | def _genrate_file(size): 8 | yield "1" 9 | yield "\0" * (size-1) 10 | return Response(stream_with_context(_genrate_file(size))) 11 | 12 | if __name__ == "__main__": 13 | app.run(debug=True, threaded=True, port=8888, host="0.0.0.0") 14 | -------------------------------------------------------------------------------- /request_merging/jsonp.php: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | outside js http status_code fuzz 7 | 8 | 9 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | 19 | 20 | *.css linguist-language=Text 21 | *.html linguist-language=Text 22 | -------------------------------------------------------------------------------- /fuzzing-Chrome-XSS-Auditor-by-HTTP-status-code/generate_phpfile.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | php_code_format = ''' 4 | ' 4 | 5 | for num in range(0x000, 0xfff): 6 | with open("{}.html".format(num), "w") as f: 7 | payload = '' 8 | if unicodedata.category(unichr(num)) == 'Cc': 9 | payload = r'\x{0:02x}'.format(num) 10 | payload = base_payload.encode('utf-8') %(payload, payload) 11 | else: 12 | payload = unichr(num) 13 | payload = (base_payload %(payload, payload)).encode('utf-8') 14 | f.write(payload) 15 | print("{}.html".format(num)) -------------------------------------------------------------------------------- /golang_https_http_server_conflict/cert.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIBuTCCASICCQD6c09wbxFRQzANBgkqhkiG9w0BAQsFADAhMR8wHQYDVQQDDBZk 3 | b21haW4tc2VjLXByb2plY3QuY29tMB4XDTE4MDIxMjEwMjYzOVoXDTI4MDIxMDEw 4 | MjYzOVowITEfMB0GA1UEAwwWZG9tYWluLXNlYy1wcm9qZWN0LmNvbTCBnzANBgkq 5 | hkiG9w0BAQEFAAOBjQAwgYkCgYEA0IAsNwBO5krnwGEjhpaOar12CUU9+3s/cafJ 6 | ZRqh0wIrO/2ebTXQD+gv/Lp5hgfsIvhfWh4xemLyv2WEt4V0eBrnESDrq5vnGFxX 7 | HPXc0aOn3OOVZ/z8LATHbFw17NN6a4ktd6Kjf1rHS3vYHiR6Avk8wcJ0MOXDQ7IJ 8 | /gbMhOcCAwEAATANBgkqhkiG9w0BAQsFAAOBgQCMMRN3VG2HUlTSl6RKwZh52phT 9 | BvJko/tpSdan3c5VUuAAZWOuYQD6XkOT+u7eWckXDaSfm7kt8jU0iHYDdP6wo6t4 10 | 1gOk0RC20GjBcp0gkFJvKfMP2oUQh809qw0sMoMpIIdq7169K+YF+Hgz8u9Y+GoJ 11 | 2G4twjCsaqG7EdEnfw== 12 | -----END CERTIFICATE----- 13 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | 2 | # 平时做的一些小实验,小代码,小Tip的收集和分享 3 | 4 | 平时做的一些如fuzz的小实验,或者写的一些小工具,其内容并不能成为一篇文章或者一个项目,但是又是可以分享的,我就放到这里来。 5 | 6 | 7 | ## 目录 8 | 9 | - [golang定义struct使用继承时如何和bson及json库兼容](./golang-use-struct-inheritance-and-bson-together.md) 10 | - [把 漏洞 或者 Writeup 拆开成一个个知识点](./onetips) 11 | - [使用Fuzz的方式对“Chrome XSS Auditor”与“HTTP状态码”的关系进行研究](./fuzzing-Chrome-XSS-Auditor-by-HTTP-status-code) 12 | - [Fuzz 尖括号跟什么字符可以使html正常解析?](./fuzzing_char_after_angel_bracket) 13 | - [firefox任意版本在HTTP1.0且HTTP状态码为304的情况下, 任何Content-type都会解析为html](./fuzzing-browser-MIME-Sniffing-by-status-code-in-HTTP1.0) 14 | - [专门用于sql注入等扫描器的url去重和比较 Python url类](./python-url-object-for-uniq) 15 | - [使用request merging bypass referer(jsonp) 检测](./request_merging) 16 | 17 | 18 | -------------------------------------------------------------------------------- /postMessage_and_addEventListener_message/postmessage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 9 | 10 | 23 | 24 | -------------------------------------------------------------------------------- /request_merging/poc.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 10 | 11 | 24 | -------------------------------------------------------------------------------- /golang_https_http_server_conflict/create_file/create_file.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "log" 5 | "os" 6 | "time" 7 | ) 8 | 9 | var filename = "" 10 | 11 | func createFile(path string) { 12 | var _, err = os.Stat(path) 13 | if os.IsNotExist(err) { 14 | var file, err = os.Create(path) 15 | if err != nil { 16 | panic(err) 17 | } 18 | defer file.Close() 19 | } 20 | } 21 | 22 | func createA() { 23 | filename = "/tmp/a" 24 | createFile(filename) 25 | log.Println(filename) 26 | } 27 | 28 | func createB() { 29 | filename = "/tmp/b" 30 | createFile(filename) 31 | log.Println(filename) 32 | } 33 | 34 | func main() { 35 | go createA() 36 | // time.Sleep(1000 * time.Microsecond) 37 | go createB() 38 | 39 | for { 40 | time.Sleep(2 * time.Microsecond) 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /request_merging/fuzz_size_of_response.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | fuzz size of response about request merging 7 | 8 | 9 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /fuzzing-Chrome-XSS-Auditor-by-HTTP-status-code/test_chrome_xss_adult.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | outside js http status_code fuzz 7 | 8 | 9 | 10 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /fuzzing-browser-MIME-Sniffing-by-status-code-in-HTTP1.0/readme.md: -------------------------------------------------------------------------------- 1 | # firefox任意版本在HTTP1.0且HTTP状态码为304的情况下, 任何Content-type都会解析为html 2 | 3 | 此Tip是我们不小心试出来的,不知道之前有没有人发现过。 4 | 5 | ## 目录: 6 | 7 | ``` 8 | ├── fuzz.html : fuzz用html文件 9 | ├── http_status_code_in_query.php : 会根据`?payload=`返回http响应的php脚本 10 | ``` 11 | 12 | ## 记录 13 | 14 | 1. firefox任意版本在HTTP1.0且HTTP状态码为304的情况下, 任何Content-type都会解析html 15 | 返回包为: 16 | ``` 17 | HTTP/1.0 304 Not Modified 18 | Date: Tue, 05 Sep 2017 12:26:32 GMT 19 | Server: Apache/2.4.23 (Unix) OpenSSL/1.0.2h PHP/7.0.9 mod_perl/2.0.8-dev Perl/v5.16.3 20 | Connection: close 21 | 22 | 23 | ``` 24 | 2. response body必须得以html标签起始 25 | 26 | ## 图 27 | 28 | ![](https://github.com/neargle/tips-note/blob/master/fuzzing-browser-MIME-Sniffing-by-status-code-in-HTTP1.0/firefox.png) 29 | 30 | ## thx 31 | 32 | - wolf 33 | - evi1m0 34 | -------------------------------------------------------------------------------- /golang_https_http_server_conflict/private.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIICXQIBAAKBgQDQgCw3AE7mSufAYSOGlo5qvXYJRT37ez9xp8llGqHTAis7/Z5t 3 | NdAP6C/8unmGB+wi+F9aHjF6YvK/ZYS3hXR4GucRIOurm+cYXFcc9dzRo6fc45Vn 4 | /PwsBMdsXDXs03priS13oqN/WsdLe9geJHoC+TzBwnQw5cNDsgn+BsyE5wIDAQAB 5 | AoGAbR9oBLFImgcCHBG7AimyB/N434k503DB1741DZFOuJ0d+5vVWtsbNfgThXYj 6 | PB7RW8waO5Qp2SAIZFvBhjt2pKKIgechCFxUMzlSshfyEi7R4c8hMFrQYxLooX9G 7 | uSped3u+4mAnv/sgzoaE4DqIMlTqcjR4dPZgyDCJV1wMQwECQQD/KmLQA98I4fm6 8 | LeJQpAUnKTGBYRDoNa+ufEpJiT5Vi8zhy/b0bK1SATqL68kkx8Lz3mGvMRP22Z0/ 9 | BCVP+anHAkEA0S64h2W6YgZoH4jToOvwJ8xBg1H9P/BjDkmMPDrfvkVNdrNoJcOz 10 | l2Gnb/jwmny+ryTSqfJJdGC/2G0c81dL4QJBAKKpMIiOjzWoaHvpGCZ0CNzoA6kI 11 | abC92JqQnQK3vMbn8dnXHjy+stZd9iaQTo9l0L+JehgmXyWzn+w2BlsvOq0CQQDH 12 | CSN/gWYE23+7cZ+cIKMT2yAC6cKEUiCOeaC7tnEqRBre9PoF5N4/DiYZPs8Az+1I 13 | DUt9dRI7b8tbDQdc6xVBAkAS4XZA7l2VBzsZ4z56rjN+sczCsXqVPGGKrd/x6lRE 14 | sLReqeFxWJlo5FSbjlQteyy5wjxET7vlmragi3hpjKSG 15 | -----END RSA PRIVATE KEY----- 16 | -------------------------------------------------------------------------------- /golang_https_http_server_conflict/app.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "log" 5 | "net" 6 | "net/http" 7 | "time" 8 | ) 9 | 10 | func handler(w http.ResponseWriter, req *http.Request) { 11 | w.Header().Set("Content-Type", "text/plain") 12 | w.Write([]byte("This is an example server.\n")) 13 | } 14 | 15 | var Server *http.Server 16 | var addr = "" 17 | 18 | func runHTTPS() { 19 | addr = ":8083" 20 | http.HandleFunc("/", handler) 21 | log.Println("https://127.0.0.1:8083/") 22 | err := http.ListenAndServeTLS(addr, "cert.pem", "private.pem", nil) 23 | if err != nil { 24 | panic(err) 25 | } 26 | } 27 | 28 | func runHTTP() { 29 | addr = ":8082" 30 | log.Println("http://127.0.0.1:8082/") 31 | ln, err := net.Listen("tcp4", addr) 32 | if err != nil { 33 | panic(err) 34 | } 35 | log.Println(ln) 36 | } 37 | 38 | func main() { 39 | 40 | go runHTTPS() 41 | // time.Sleep(1000 * time.Microsecond) 42 | go runHTTP() 43 | 44 | for { 45 | time.Sleep(2 * time.Microsecond) 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /golang-use-struct-inheritance-and-bson-together.md: -------------------------------------------------------------------------------- 1 | # golang定义struct使用继承时如何和bson及json库兼容 2 | 3 | 情况如下: 4 | 5 | ```go 6 | type Example struct { 7 | ID bson.ObjectId `bson:"_id,omitempty" json:"_id,omitempty"` 8 | baseModel 9 | } 10 | ``` 11 | 12 | 1. 使用小写开头的基结构体,可以使转换而成的bson或json结构不带baseModel 13 | 2. 在自动转化为bson时,例如mgo.v2在insert的时候如果带有小写的基结构体,程序会爆以下错误: 14 | 15 | ``` 16 | reflect.Value.Interface: cannot return value obtained from unexported field or method 17 | ``` 18 | 19 | 解决方法: 20 | 21 | ```go 22 | type Example struct { 23 | ID bson.ObjectId `bson:"_id,omitempty" json:"_id,omitempty"` 24 | baseModel `bson:",inline"` 25 | } 26 | ``` 27 | 28 | 定义bson为inline,则在自动转换的时候,mgo.v2不会用反射去猜测baseModel的结构。 29 | 30 | 官方解释: 31 | 32 | > inline Inline the field, which must be a struct or a map, 33 | > causing all of its fields or keys to be processed as if 34 | > they were part of the outer struct. For maps, keys must 35 | > not conflict with the bson keys of other struct fields. 36 | -------------------------------------------------------------------------------- /postMessage_and_addEventListener_message/topwindow.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 9 | 10 | 11 | 31 | 32 | -------------------------------------------------------------------------------- /request_merging/iframe_request_merging.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | iframe request merging 7 | 8 | 9 | 10 | 11 | 12 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /fuzzing-Chrome-XSS-Auditor-by-HTTP-status-code/test_chrome_js_outside_execute.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | outside js http status_code fuzz 7 | 8 | 9 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /fuzzing-Chrome-XSS-Auditor-by-HTTP-status-code/readme.md: -------------------------------------------------------------------------------- 1 | # 使用Fuzz的方式对“Chrome XSS Auditor”与“HTTP状态码”的关系进行研究 2 | 3 | ``` 4 | - fuzzfile 5 | │   ── 200.php 6 | │   ├── 201.php 7 | │   ├── 202.php 8 | │   ├── 203.php 9 | │   ├── ***.php 10 | │   └── 308.php 11 | ├── generate_phpfile.py 12 | ├── readme.md 13 | ├── status_code_in_phpself.php 14 | ├── test.html 15 | ├── test_chrome_js_outside_execute.html 16 | ├── test_chrome_xss_adult.html 17 | └── xss.php 18 | ``` 19 | 20 | - fuzzfile : python脚本生成的php文件所放的文件夹 21 | - generate_phpfile.py : 生成返回不同状态码的php脚本的python脚本 22 | - status_code_in_phpself.php : 最初使用这个脚本获取`_SERVER["PHP_SELF"]`或get请求来更改状态码 23 | - test.html : html 测试文件 24 | - test_chrome_js_outside_execute.html : Fuzz那些状态码内的内容可以在` 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /python-url-object-for-uniq/url_filter.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 针对sql注入的url去重方法 3 | ''' 4 | 5 | from urllib.parse import ParseResult, parse_qsl, urlencode 6 | from urllib.parse import ( 7 | urlparse as _urlparse, 8 | urlunsplit as _urlunsplit 9 | ) 10 | 11 | 12 | def dict_key_equal(dict1, dict2): 13 | '''对两个字典的对比,只对比key是否相同''' 14 | return not bool(set(dict1.keys()).difference(set(dict2.keys()))) 15 | 16 | 17 | class URL(ParseResult): 18 | 19 | def __eq__(self, other): 20 | '''对两个URL对象的比较,GET请求只匹配参数。其他的因素全匹配。''' 21 | if isinstance(other, self.__class__): 22 | _str_key_lst = ("scheme", "netloc", "path", "params", "fragment") 23 | _dict_key_lst = ("query",) 24 | for key in _str_key_lst: 25 | if getattr(self ,key) != getattr(other ,key): 26 | return False 27 | for key in _dict_key_lst: 28 | if not dict_key_equal( 29 | getattr(self ,key), getattr(other ,key) 30 | ): 31 | return False 32 | return True 33 | return False 34 | 35 | def __ne__(self, other): 36 | return not self.__eq__(other) 37 | 38 | def __hash__(self): 39 | _lst = list(tuple(self)) 40 | _lst[4] = tuple(sorted(_lst[4].keys())) 41 | return hash(tuple(_lst)) 42 | 43 | 44 | def urlparse(url, scheme='', allow_fragments=True): 45 | _presult = _urlparse( 46 | url, scheme=scheme, allow_fragments=allow_fragments 47 | ) 48 | _lst = list(_presult) 49 | _lst[4] = dict(parse_qsl(_lst[4])) 50 | return URL(*_lst) 51 | 52 | 53 | def urlunsplit(components): 54 | _lst = list(components) 55 | _lst[4] = urlencode(_lst[4]) 56 | return ParseResult(*_lst).geturl() 57 | 58 | 59 | def test_url_object_equal(): 60 | origin_url = urlparse("http://example.com/x?a=1&b=2") 61 | for url in ( 62 | urlparse("http://example.com/x?a=1&b=2"), 63 | urlparse("http://example.com/x?a=1&b=3"), 64 | urlparse("http://example.com/x?a=2&b=3") 65 | ): 66 | assert (origin_url == url) is True 67 | assert (origin_url != url) is False 68 | assert len(set((origin_url, url))) is 1 69 | 70 | for url in ( 71 | urlparse("http://example.com/x?a=2&c=3"), 72 | urlparse("http://aaaa.com/x?a=1&b=2") 73 | ): 74 | assert (origin_url == url) is False 75 | assert (origin_url != url) is True 76 | assert len(set((origin_url, url))) is 2 77 | 78 | 79 | if __name__ == '__main__': 80 | test_url_object_equal() 81 | print("[*] all tests passed!") 82 | -------------------------------------------------------------------------------- /request_merging/readme.md: -------------------------------------------------------------------------------- 1 | # 使用request merging bypass referer(jsonp) 检测 2 | 3 | ## 1. 关于request merging和其会产生的问题 4 | 5 | request merging : 浏览器会把多次相同的请求(并非所有请求)合并成一次,以加快资源加载速度。 6 | 7 | e.g. 8 | ```html 9 | 10 | 11 | 12 | ``` 13 | 只会请求并加载一次 "http://0.0.0.0:8888/jsonp/1" 资源。 14 | 15 | *曾经有研究指出,这种请求合并想象在iframe里也存在*,那么浏览器的这种特性就可以用来bypass部分程序的referer的判断,如jsonp的防御机制。 16 | 17 | ## 2. 环境和POC 18 | 19 | 绕过referer检测,攻击者能否拿到进行referer保护的用户信息? 20 | 21 | - 攻击者服务器: http://example.com:8081 22 | - 目标服务器: http://example.com:8082 23 | - referer检测: referer是否以“http://example.com:8082”开头 24 | - 目标: 攻击者拿到属于用户的 "security content" 25 | 26 | ### 环境: 27 | 28 | /jsonp.php 29 | ```php 30 | 52 | 53 | 54 | index in http://0.0.0.0 55 | 56 | 57 | 58 | 61 | 62 | 63 | 64 | ``` 65 | 66 | ### poc 67 | http://example.com:8081/poc.html 68 | ``` 69 | 70 | 71 | 74 | ``` 75 | 76 | 正常情况这个poc是没有办法获得jsonp里面的信息的,因为不能bypass`startsWith($referrer, "http://example.com:8082")`的检测。 77 | 但是在request merging的情况下,浏览器因为script资源的url是相同的,所以它只会请求`http://example.com:8082/jsonp.php`一次,则我们可以在`example.com:8081`里拿到只有`example.com:8082`可以拿到的资源。 78 | 79 | ## 第一次实验 80 | 81 | 访问:http://example.com:8081/poc.html 82 | 83 | ![](./img0.png) 84 | 85 | 失败了... 86 | 之后我开始不正经了... 87 | 88 | ## fuzz response size in script src 89 | 90 | 难不成是response请求包大小的问题?请求太小的情况下,没有必要合并请求,所以浏览器直接不合并了?fuzz一下看看多大的请求会被合并。 91 | 92 | 代码: 93 | flask: 94 | ```python 95 | from flask import Response, Flask, stream_with_context 96 | 97 | app = Flask(__name__) 98 | 99 | @app.route('/jsonp/') 100 | def jsonp(size): 101 | def _genrate_file(size): 102 | yield "1" 103 | yield "\0" * (size-1) 104 | return Response(stream_with_context(_genrate_file(size))) 105 | 106 | if __name__ == "__main__": 107 | app.run(debug=True, threaded=True, port=8888, host="0.0.0.0") 108 | ``` 109 | html: 110 | ``` 111 | 112 | 113 | 114 | 115 | fuzz size of response about request merging 116 | 117 | 118 | 135 | 136 | 137 | ``` 138 | 实验结果,所有请求都合并了。我连1024都没有乘。很小很小的请求都会合并。 139 | 140 | ## iframe并不会merging?? 141 | 142 | ```html 143 | 144 | 145 | 146 | 147 | iframe request merging 148 | 149 | 150 | 151 | 152 | 153 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | ``` 174 | 175 | 测试了三次。果然都没有合并请求... 176 | 177 | 绝招!问大佬: https://twitter.com/nearg1e/status/903297400797663232 178 | 179 | @filedescriptor 是twitter上专注于浏览器安全的安全研究员,之前的“iframe也会发生 request merging”的结论也是他得出来的。 180 | 181 | 请教结果: 5月12日的时候验证chrome已经修复了该问题。好吧居然fix了。 182 | 183 | ## 大部分的国产浏览器依然受影响。 184 | 185 | 之前windows上对多款浏览器进行过UXSS的测试和特权域API的分析,所以windows环境里还有多款国产浏览器。我们知道大部分国产浏览器是基于chromium的,而且版本更新并不会像chrome那么勤快,特别是内核的更新一直是相对比较缓慢的。很多Nday都可以用(可是src不收呀!)。 186 | 187 | test in 360se 8.2.1.340 188 | 189 | ![](./img1.png) 190 | 191 | poc修改为: 192 | ```html 193 | 194 | 195 | 196 | 197 | ``` 198 | 199 | 这样保证了,攻击者域中的请求后执行。 200 | 思路验证成功。 201 | 202 | 在 IE11和Edge上 好像现在依旧没有fix该问题。我这边的版本可能稍微低了一点,POC都是可用的。 203 | 204 | - Microsoft Edge 40.15063.0.0 205 | - IE 11.296.15063.0 206 | 207 | ## other 208 | 209 | 现在很多浏览器漏洞(bug)都是和新特性(feature)相关的,或许request merging还有别的用处? 210 | 211 | 想测试自己所用的浏览器是否受印象只需访问:[http://blog.neargle.com/tips-note/request_merging/iframe_merging_poc.html](http://blog.neargle.com/tips-note/request_merging/iframe_merging_poc.html),开发者工具中网络对“https://cdn.bootcss.com/jquery/3.2.1/jquery.js”的请求只进行了一次,那么就是受影响的。 212 | 213 | ## link 214 | 215 | - https://twitter.com/nearg1e/status/903297400797663232 216 | - Exploiting the unexploitable with lesser known browser tricks from filedescriptor 217 | 218 | 219 | 220 | -------------------------------------------------------------------------------- /request_merging/readme.bak.md.txt: -------------------------------------------------------------------------------- 1 | # 使用request merging bypass referer(jsonp) 检测 2 | 3 | 所有代码在: 4 | https://github.com/neargle/tips-note/tree/master/request_merging 5 | 6 | ## 1. 关于request merging和其会产生的问题 7 | 8 | request merging : 浏览器会把多次相同的请求(并非所有请求)合并成一次,以加快资源加载速度。 9 | 10 | e.g. 11 | ```html 12 | 13 | 14 | 15 | ``` 16 | 只会请求并加载一次 "http://0.0.0.0:8888/jsonp/1" 资源。 17 | 18 | *曾经有研究指出,这种请求合并想象在iframe里也存在*,那么浏览器的这种特性就可以用来bypass部分程序的referer的判断,如jsonp的防御机制。 19 | 20 | ## 2. 环境和POC 21 | 22 | 绕过referer检测,攻击者能否拿到进行referer保护的用户信息? 23 | 24 | - 攻击者服务器: http://example.com:8081 25 | - 目标服务器: http://example.com:8082 26 | - referer检测: referer是否以“http://example.com:8082”开头 27 | - 目标: 攻击者拿到属于用户的 "security content" 28 | 29 | ### 环境: 30 | 31 | /jsonp.php 32 | ```php 33 | 55 | 56 | 57 | index in http://0.0.0.0 58 | 59 | 60 | 61 | 64 | 65 | 66 | 67 | ``` 68 | 69 | ### poc 70 | http://example.com:8081/poc.html 71 | ``` 72 | 73 | 74 | 77 | ``` 78 | 79 | 正常情况这个poc是没有办法获得jsonp里面的信息的,因为不能bypass`startsWith($referrer, "http://example.com:8082")`的检测。 80 | 但是在request merging的情况下,浏览器因为script资源的url是相同的,所以它只会请求`http://example.com:8082/jsonp.php`一次,则我们可以在`example.com:8081`里拿到只有`example.com:8082`可以拿到的资源。 81 | 82 | ## 第一次实验 83 | 84 | 访问:http://example.com:8081/poc.html 85 | 86 | ![](http://ww1.sinaimg.cn/large/005y7Ba5gy1fj4612z2h6j310q0fc3zw.jpg) 87 | 88 | 失败了... 89 | 之后我开始不正经了... 90 | 91 | ## fuzz response size in script src 92 | 93 | 难不成是response请求包大小的问题?请求太小的情况下,没有必要合并请求,所以浏览器直接不合并了?fuzz一下看看多大的请求会被合并。 94 | 95 | 代码: 96 | flask: 97 | ```python 98 | from flask import Response, Flask, stream_with_context 99 | 100 | app = Flask(__name__) 101 | 102 | @app.route('/jsonp/') 103 | def jsonp(size): 104 | def _genrate_file(size): 105 | yield "1" 106 | yield "\0" * (size-1) 107 | return Response(stream_with_context(_genrate_file(size))) 108 | 109 | if __name__ == "__main__": 110 | app.run(debug=True, threaded=True, port=8888, host="0.0.0.0") 111 | ``` 112 | html: 113 | ``` 114 | 115 | 116 | 117 | 118 | fuzz size of response about request merging 119 | 120 | 121 | 138 | 139 | 140 | ``` 141 | 实验结果,所有请求都合并了。我连1024都没有乘。很小很小的请求都会合并。 142 | 143 | ## iframe并不会merging?? 144 | 145 | ```html 146 | 147 | 148 | 149 | 150 | iframe request merging 151 | 152 | 153 | 154 | 155 | 156 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | ``` 177 | 178 | 测试了三次。果然都没有合并请求... 179 | 180 | 绝招!问大佬: https://twitter.com/nearg1e/status/903297400797663232 181 | 182 | @filedescriptor 是twitter上专注于浏览器安全的安全研究员,之前的“iframe也会发生 request merging”的结论也是他得出来的。 183 | 184 | 请教结果: 5月12日的时候验证chrome已经修复了该问题。好吧居然fix了。 185 | 186 | ## 大部分的国产浏览器依然受影响。 187 | 188 | 之前windows上对多款浏览器进行过UXSS的测试和特权域API的分析,所以windows环境里还有多款国产浏览器。我们知道大部分国产浏览器是基于chromium的,而且版本更新并不会像chrome那么勤快,特别是内核的更新一直是相对比较缓慢的。很多Nday都可以用(可是src不收呀!)。 189 | 190 | test in 360se 8.2.1.340 191 | 192 | ![](http://ww1.sinaimg.cn/large/005y7Ba5gy1fj46nc4gr1j31d90nowgp.jpg) 193 | 194 | poc修改为: 195 | ```html 196 | 197 | 198 | 199 | 200 | ``` 201 | 这样保证了,攻击者域中的请求后执行。 202 | 203 | 从图片中可以看出,我们在 “example.com:8081” 域中访问到只有在 “example.com:8082” 才能访问到的资源,而且请求列表中,浏览器只请求jsonp资源一次。 204 | 思路验证成功。 205 | 206 | 在 IE11和Edge上 好像现在依旧没有fix该问题。我这边的版本可能稍微低了一点,POC都是可用的。 207 | 208 | - Microsoft Edge 40.15063.0.0 209 | - IE 11.296.15063.0 210 | 211 | ## other 212 | 213 | 现在很多浏览器漏洞(bug)都是和新特性(feature)相关的,或许request merging还有别的用处? 214 | 215 | 想测试自己所用的浏览器是否受印象只需访问:[http://blog.neargle.com/tips-note/request_merging/iframe_merging_poc.html](http://blog.neargle.com/tips-note/request_merging/iframe_merging_poc.html),开发者工具中网络对“https://cdn.bootcss.com/jquery/3.2.1/jquery.js”的请求只进行了一次,那么就是受影响的。 216 | 217 | ## link 218 | 219 | - https://twitter.com/nearg1e/status/903297400797663232 220 | - Exploiting the unexploitable with lesser known browser tricks from filedescriptor 221 | 222 | ## Thanks 223 | 224 | @filedescriptor -------------------------------------------------------------------------------- /xunfeng_icmp_scan_test.py: -------------------------------------------------------------------------------- 1 | # coding:utf-8 2 | import threading 3 | import socket 4 | import struct 5 | import os 6 | import sys 7 | import time 8 | import array 9 | import logging 10 | 11 | log = logging.getLogger('send_test') 12 | console_handler = logging.StreamHandler(sys.stdout) 13 | log.addHandler(console_handler) 14 | log.setLevel(logging.INFO) 15 | 16 | iplst_txt = ''' 17 | 123.125.66.101 18 | 123.125.66.103 19 | 123.125.66.104 20 | 123.125.66.106 21 | 123.125.66.107 22 | 123.125.66.109 23 | 123.125.66.110 24 | 123.125.66.111 25 | 123.125.66.113 26 | 123.125.66.114 27 | 123.125.66.100 28 | 123.125.66.118 29 | 123.125.66.102 30 | 123.125.66.117 31 | 123.125.66.120 32 | 123.125.66.119 33 | 123.125.66.123 34 | 123.125.66.108 35 | 123.125.66.105 36 | 123.125.66.125 37 | 123.125.66.128 38 | 123.125.66.127 39 | 123.125.66.130 40 | 123.125.66.131 41 | 123.125.66.112 42 | 123.125.66.115 43 | 123.125.66.116 44 | 123.125.66.134 45 | 123.125.66.133 46 | 123.125.66.129 47 | 123.125.66.124 48 | 123.125.66.122 49 | 123.125.66.132 50 | 123.125.66.16 51 | 123.125.66.15 52 | 123.125.66.17 53 | 123.125.66.18 54 | 123.125.66.19 55 | 123.125.66.20 56 | 123.125.66.21 57 | 123.125.66.22 58 | 123.125.66.23 59 | 123.125.66.24 60 | 123.125.66.25 61 | 123.125.66.28 62 | 123.125.66.30 63 | 123.125.66.33 64 | 123.125.66.34 65 | 123.125.66.35 66 | 123.125.66.29 67 | 123.125.66.27 68 | 123.125.66.38 69 | 123.125.66.40 70 | 123.125.66.41 71 | 123.125.66.42 72 | 123.125.66.26 73 | 123.125.66.31 74 | 123.125.66.32 75 | 123.125.66.46 76 | 123.125.66.45 77 | 123.125.66.44 78 | 123.125.66.49 79 | 123.125.66.47 80 | 123.125.66.48 81 | 123.125.66.50 82 | 123.125.66.52 83 | 123.125.66.54 84 | 123.125.66.36 85 | 123.125.66.55 86 | 123.125.66.56 87 | 123.125.66.57 88 | 123.125.66.58 89 | 123.125.66.51 90 | 123.125.66.39 91 | 123.125.66.65 92 | 123.125.66.37 93 | 123.125.66.66 94 | 123.125.66.67 95 | 123.125.66.43 96 | 123.125.66.70 97 | 123.125.66.53 98 | 123.125.66.62 99 | 123.125.66.59 100 | 123.125.66.74 101 | 123.125.66.75 102 | 123.125.66.69 103 | 123.125.66.68 104 | 123.125.66.77 105 | 123.125.66.61 106 | 123.125.66.71 107 | 123.125.66.64 108 | 123.125.66.81 109 | 123.125.66.80 110 | 123.125.66.82 111 | 123.125.66.72 112 | 123.125.66.83 113 | 123.125.66.85 114 | 123.125.66.86 115 | 123.125.66.87 116 | 123.125.66.89 117 | 123.125.66.90 118 | 123.125.66.91 119 | 123.125.66.73 120 | 123.125.66.92 121 | 123.125.66.93 122 | 123.125.66.94 123 | 123.125.66.96 124 | 123.125.66.76 125 | 123.125.66.79 126 | 123.125.66.98 127 | 123.125.66.78 128 | 123.125.66.99 129 | 123.125.66.84 130 | 123.125.66.95 131 | 123.125.71.101 132 | 123.125.71.102 133 | 123.125.71.104 134 | 123.125.71.105 135 | 123.125.71.106 136 | 123.125.71.100 137 | 123.125.71.107 138 | 123.125.71.108 139 | 123.125.71.112 140 | 123.125.71.103 141 | 123.125.71.110 142 | 123.125.71.11 143 | 123.125.71.109 144 | 123.125.71.117 145 | 123.125.71.115 146 | 123.125.71.116 147 | 123.125.71.113 148 | 123.125.71.114 149 | 123.125.71.121 150 | 123.125.71.120 151 | 123.125.71.124 152 | 123.125.71.122 153 | 123.125.71.125 154 | 123.125.71.126 155 | 123.125.71.127 156 | 123.125.71.123 157 | 123.125.71.129 158 | 123.125.71.130 159 | 123.125.71.13 160 | 123.125.71.132 161 | 123.125.71.135 162 | 123.125.71.134 163 | 123.125.71.138 164 | 123.125.71.14 165 | 123.125.71.140 166 | 123.125.71.141 167 | 123.125.71.142 168 | 123.125.71.131 169 | 123.125.71.128 170 | 123.125.71.12 171 | 123.125.71.144 172 | 123.125.71.136 173 | 123.125.71.146 174 | 123.125.71.147 175 | 123.125.71.137 176 | 123.125.71.148 177 | 123.125.71.139 178 | 123.125.71.133 179 | 123.125.71.149 180 | 123.125.71.150 181 | 123.125.71.15 182 | 123.125.71.151 183 | 123.125.71.155 184 | 123.125.71.152 185 | 123.125.71.153 186 | 123.125.71.156 187 | 123.125.71.154 188 | 123.125.71.160 189 | 123.125.71.158 190 | 123.125.71.159 191 | 123.125.71.157 192 | 123.125.71.16 193 | 123.125.71.143 194 | 123.125.71.161 195 | 123.125.71.17 196 | 123.125.71.19 197 | 123.125.71.145 198 | 123.125.71.18 199 | 123.125.71.21 200 | 123.125.71.20 201 | 123.125.71.22 202 | 123.125.71.25 203 | 123.125.71.26 204 | 123.125.71.28 205 | 123.125.71.30 206 | 123.125.71.31 207 | 123.125.71.23 208 | 123.125.71.32 209 | 123.125.71.24 210 | 123.125.71.34 211 | 123.125.71.33 212 | 123.125.71.38 213 | 123.125.71.36 214 | 123.125.71.27 215 | 123.125.71.37 216 | 123.125.71.40 217 | 123.125.71.29 218 | 123.125.71.43 219 | 123.125.71.41 220 | 123.125.71.45 221 | 123.125.71.48 222 | 123.125.71.47 223 | 123.125.71.46 224 | 123.125.71.39 225 | 123.125.71.42 226 | 123.125.71.52 227 | 123.125.71.49 228 | 123.125.71.44 229 | 123.125.71.55 230 | 123.125.71.50 231 | 123.125.71.53 232 | 123.125.71.54 233 | 123.125.71.56 234 | 123.125.71.60 235 | 123.125.71.59 236 | 123.125.71.57 237 | 123.125.71.58 238 | 123.125.71.35 239 | 123.125.71.64 240 | 123.125.71.63 241 | 123.125.71.66 242 | 123.125.71.67 243 | 123.125.71.70 244 | 123.125.71.69 245 | 123.125.71.68 246 | 123.125.71.71 247 | 123.125.71.72 248 | 123.125.71.73 249 | 123.125.71.75 250 | 123.125.71.78 251 | 123.125.71.77 252 | 123.125.71.79 253 | 123.125.71.74 254 | 123.125.71.80 255 | 123.125.71.76 256 | 123.125.71.84 257 | 123.125.71.81 258 | 123.125.71.82 259 | 123.125.71.85 260 | 123.125.71.83 261 | 123.125.71.87 262 | 123.125.71.89 263 | 123.125.71.86 264 | 123.125.71.91 265 | 123.125.71.90 266 | 123.125.71.92 267 | 123.125.71.93 268 | 123.125.71.94 269 | 123.125.71.51 270 | 123.125.71.98 271 | 123.125.71.95 272 | 123.125.71.88 273 | 123.125.71.96 274 | 123.125.71.97 275 | 123.125.71.99 276 | 123.125.71.62 277 | 123.125.71.65 278 | 180.76.15.10 279 | 180.76.15.103 280 | 180.76.15.105 281 | 180.76.15.100 282 | 180.76.15.106 283 | 180.76.15.108 284 | 180.76.15.104 285 | 180.76.15.1 286 | 180.76.15.110 287 | 180.76.15.109 288 | 180.76.15.102 289 | 180.76.15.111 290 | 180.76.15.116 291 | 180.76.15.11 292 | 180.76.15.107 293 | 180.76.15.101 294 | 180.76.15.12 295 | 180.76.15.113 296 | 180.76.15.112 297 | 180.76.15.117 298 | 180.76.15.121 299 | 180.76.15.115 300 | 180.76.15.114 301 | 180.76.15.118 302 | 180.76.15.126 303 | 180.76.15.119 304 | 180.76.15.124 305 | 180.76.15.13 306 | 180.76.15.120 307 | 180.76.15.130 308 | 180.76.15.123 309 | 180.76.15.134 310 | 180.76.15.135 311 | 180.76.15.136 312 | 180.76.15.122 313 | 180.76.15.137 314 | 180.76.15.138 315 | 180.76.15.139 316 | 180.76.15.14 317 | 180.76.15.140 318 | 180.76.15.141 319 | 180.76.15.142 320 | 180.76.15.143 321 | 180.76.15.144 322 | 180.76.15.145 323 | 180.76.15.146 324 | 180.76.15.147 325 | 180.76.15.148 326 | 180.76.15.149 327 | 180.76.15.15 328 | 180.76.15.150 329 | 180.76.15.151 330 | 180.76.15.152 331 | 180.76.15.154 332 | 180.76.15.153 333 | 180.76.15.129 334 | 180.76.15.156 335 | 180.76.15.155 336 | 180.76.15.157 337 | 180.76.15.158 338 | 180.76.15.16 339 | 180.76.15.159 340 | 180.76.15.162 341 | 180.76.15.161 342 | 180.76.15.160 343 | 180.76.15.163 344 | 180.76.15.128 345 | 180.76.15.127 346 | 180.76.15.131 347 | 180.76.15.166 348 | 180.76.15.165 349 | 180.76.15.133 350 | 180.76.15.164 351 | 180.76.15.17 352 | 180.76.15.132 353 | 180.76.15.170 354 | 180.76.15.167 355 | 180.76.15.175 356 | 180.76.15.169 357 | 180.76.15.172 358 | 180.76.15.168 359 | 180.76.15.18 360 | 180.76.15.178 361 | 180.76.15.174 362 | 180.76.15.173 363 | 180.76.15.171 364 | 180.76.15.184 365 | 180.76.15.179 366 | 180.76.15.177 367 | 180.76.15.180 368 | 180.76.15.186 369 | 180.76.15.182 370 | 180.76.15.176 371 | 180.76.15.190 372 | 180.76.15.185 373 | 180.76.15.181 374 | 180.76.15.187 375 | 180.76.15.19 376 | 180.76.15.193 377 | 180.76.15.192 378 | 180.76.15.197 379 | 180.76.15.196 380 | 180.76.15.183 381 | 180.76.15.188 382 | 180.76.15.20 383 | 180.76.15.189 384 | 180.76.15.201 385 | 180.76.15.200 386 | 180.76.15.194 387 | 180.76.15.195 388 | 180.76.15.198 389 | 180.76.15.199 390 | 180.76.15.2 391 | 180.76.15.203 392 | 180.76.15.206 393 | 180.76.15.191 394 | 180.76.15.209 395 | 180.76.15.210 396 | 180.76.15.212 397 | 180.76.15.211 398 | 180.76.15.208 399 | 180.76.15.202 400 | 180.76.15.215 401 | 180.76.15.21 402 | 180.76.15.205 403 | 180.76.15.213 404 | 180.76.15.219 405 | 180.76.15.220 406 | 180.76.15.22 407 | 180.76.15.222 408 | 180.76.15.223 409 | 180.76.15.216 410 | 180.76.15.226 411 | 180.76.15.217 412 | 180.76.15.221 413 | 180.76.15.214 414 | 180.76.15.23 415 | 180.76.15.207 416 | 180.76.15.218 417 | 180.76.15.232 418 | 180.76.15.227 419 | 180.76.15.225 420 | 180.76.15.228 421 | 180.76.15.234 422 | 180.76.15.229 423 | 180.76.15.230 424 | 180.76.15.231 425 | 180.76.15.24 426 | 180.76.15.239 427 | 180.76.15.236 428 | 180.76.15.237 429 | 180.76.15.235 430 | 180.76.15.243 431 | 180.76.15.233 432 | 180.76.15.242 433 | 180.76.15.245 434 | 180.76.15.224 435 | 180.76.15.248 436 | 180.76.15.244 437 | 180.76.15.240 438 | 180.76.15.25 439 | 180.76.15.246 440 | 180.76.15.249 441 | 180.76.15.254 442 | 180.76.15.251 443 | 180.76.15.247 444 | 180.76.15.27 445 | 180.76.15.28 446 | 180.76.15.26 447 | 180.76.15.30 448 | 180.76.15.31 449 | 180.76.15.32 450 | 180.76.15.33 451 | 180.76.15.3 452 | 180.76.15.241 453 | 180.76.15.252 454 | 180.76.15.34 455 | 180.76.15.35 456 | 180.76.15.238 457 | 180.76.15.38 458 | 180.76.15.29 459 | 180.76.15.40 460 | 180.76.15.42 461 | 180.76.15.43 462 | 180.76.15.39 463 | 180.76.15.253 464 | 180.76.15.46 465 | 180.76.15.44 466 | 180.76.15.47 467 | 180.76.15.41 468 | 180.76.15.250 469 | 180.76.15.4 470 | 180.76.15.51 471 | 180.76.15.45 472 | 180.76.15.52 473 | 180.76.15.48 474 | 180.76.15.49 475 | 180.76.15.5 476 | 180.76.15.50 477 | 180.76.15.57 478 | 180.76.15.36 479 | 180.76.15.6 480 | 180.76.15.54 481 | 180.76.15.37 482 | 180.76.15.58 483 | 180.76.15.63 484 | 180.76.15.61 485 | 180.76.15.55 486 | 180.76.15.56 487 | 180.76.15.53 488 | 180.76.15.62 489 | 180.76.15.60 490 | 180.76.15.67 491 | 180.76.15.59 492 | 180.76.15.7 493 | 180.76.15.65 494 | 180.76.15.66 495 | 180.76.15.64 496 | 180.76.15.70 497 | 180.76.15.75 498 | 180.76.15.68 499 | 180.76.15.76 500 | 180.76.15.71 501 | 180.76.15.79 502 | 180.76.15.69 503 | 180.76.15.72 504 | 180.76.15.73 505 | 180.76.15.77 506 | 180.76.15.80 507 | 180.76.15.74 508 | 180.76.15.83 509 | 180.76.15.81 510 | 180.76.15.84 511 | 180.76.15.82 512 | 180.76.15.9 513 | 180.76.15.8 514 | 180.76.15.78 515 | 180.76.15.92 516 | 180.76.15.86 517 | 180.76.15.88 518 | 180.76.15.94 519 | 180.76.15.89 520 | 180.76.15.87 521 | 180.76.15.90 522 | 180.76.15.97 523 | 180.76.15.85 524 | 180.76.15.91 525 | 180.76.15.93 526 | 180.76.15.96 527 | 180.76.15.99 528 | 180.76.15.95 529 | 180.76.15.98 530 | 180.76.5.100 531 | 180.76.5.101 532 | 180.76.5.10 533 | 180.76.5.102 534 | 180.76.5.103 535 | 180.76.5.1 536 | 180.76.5.106 537 | 180.76.5.104 538 | 180.76.5.108 539 | 180.76.5.107 540 | 180.76.5.110 541 | 180.76.5.105 542 | 180.76.5.111 543 | 180.76.5.11 544 | 180.76.5.116 545 | 180.76.5.119 546 | 180.76.5.113 547 | 180.76.5.112 548 | 180.76.5.115 549 | 180.76.5.120 550 | 180.76.5.121 551 | 180.76.5.12 552 | 180.76.5.117 553 | 180.76.5.122 554 | 180.76.5.124 555 | 180.76.5.118 556 | 180.76.5.126 557 | 180.76.5.109 558 | 180.76.5.123 559 | 180.76.5.129 560 | 180.76.5.13 561 | 180.76.5.130 562 | 180.76.5.128 563 | 180.76.5.132 564 | 180.76.5.125 565 | 180.76.5.135 566 | 180.76.5.134 567 | 180.76.5.127 568 | 180.76.5.133 569 | 180.76.5.136 570 | 180.76.5.14 571 | 180.76.5.142 572 | 180.76.5.141 573 | 180.76.5.139 574 | 180.76.5.137 575 | 180.76.5.140 576 | 180.76.5.138 577 | 180.76.5.143 578 | 180.76.5.146 579 | 180.76.5.144 580 | 180.76.5.131 581 | 180.76.5.148 582 | 180.76.5.151 583 | 180.76.5.150 584 | 180.76.5.155 585 | 180.76.5.153 586 | 180.76.5.149 587 | 180.76.5.157 588 | 180.76.5.145 589 | 180.76.5.154 590 | 180.76.5.158 591 | 180.76.5.147 592 | 180.76.5.16 593 | 180.76.5.159 594 | 180.76.5.161 595 | 180.76.5.15 596 | 180.76.5.163 597 | 180.76.5.162 598 | 180.76.5.152 599 | 180.76.5.167 600 | 180.76.5.169 601 | 180.76.5.17 602 | 180.76.5.165 603 | 180.76.5.168 604 | 180.76.5.171 605 | 180.76.5.170 606 | 180.76.5.156 607 | 180.76.5.173 608 | 180.76.5.172 609 | 180.76.5.174 610 | 180.76.5.176 611 | 180.76.5.175 612 | 180.76.5.178 613 | 180.76.5.177 614 | 180.76.5.179 615 | 180.76.5.18 616 | 180.76.5.180 617 | 180.76.5.181 618 | 180.76.5.182 619 | 180.76.5.185 620 | 180.76.5.187 621 | 180.76.5.183 622 | 180.76.5.164 623 | 180.76.5.189 624 | 180.76.5.184 625 | 180.76.5.160 626 | 180.76.5.19 627 | 180.76.5.190 628 | 180.76.5.186 629 | 180.76.5.188 630 | 180.76.5.192 631 | 180.76.5.193 632 | 180.76.5.194 633 | 180.76.5.196 634 | 180.76.5.199 635 | 180.76.5.2 636 | 180.76.5.20 637 | 180.76.5.197 638 | 180.76.5.201 639 | 180.76.5.200 640 | 180.76.5.204 641 | 180.76.5.166 642 | 180.76.5.206 643 | 180.76.5.207 644 | 180.76.5.205 645 | 180.76.5.191 646 | 180.76.5.209 647 | 180.76.5.210 648 | 180.76.5.208 649 | 180.76.5.203 650 | 180.76.5.212 651 | 180.76.5.211 652 | 180.76.5.21 653 | 180.76.5.213 654 | 180.76.5.214 655 | 180.76.5.202 656 | 180.76.5.215 657 | 180.76.5.217 658 | 180.76.5.218 659 | 180.76.5.219 660 | 180.76.5.221 661 | 180.76.5.198 662 | 180.76.5.195 663 | 180.76.5.225 664 | 180.76.5.227 665 | 180.76.5.228 666 | 180.76.5.216 667 | 180.76.5.229 668 | 180.76.5.220 669 | 180.76.5.22 670 | 180.76.5.230 671 | 180.76.5.223 672 | 180.76.5.222 673 | 180.76.5.224 674 | 180.76.5.235 675 | 180.76.5.226 676 | 180.76.5.236 677 | 180.76.5.23 678 | 180.76.5.231 679 | 180.76.5.240 680 | 180.76.5.233 681 | 180.76.5.241 682 | 180.76.5.232 683 | 180.76.5.234 684 | 180.76.5.242 685 | 180.76.5.244 686 | 180.76.5.237 687 | 180.76.5.238 688 | 180.76.5.239 689 | 180.76.5.24 690 | 180.76.5.25 691 | 180.76.5.250 692 | 180.76.5.245 693 | 180.76.5.248 694 | 180.76.5.243 695 | 180.76.5.247 696 | 180.76.5.254 697 | 180.76.5.249 698 | 180.76.5.27 699 | 180.76.5.29 700 | 180.76.5.3 701 | 180.76.5.30 702 | 180.76.5.31 703 | 180.76.5.251 704 | 180.76.5.253 705 | 180.76.5.246 706 | 180.76.5.33 707 | 180.76.5.252 708 | 180.76.5.35 709 | 180.76.5.38 710 | 180.76.5.34 711 | 180.76.5.39 712 | 180.76.5.40 713 | 180.76.5.4 714 | 180.76.5.26 715 | 180.76.5.42 716 | 180.76.5.32 717 | 180.76.5.36 718 | 180.76.5.41 719 | 180.76.5.37 720 | 180.76.5.49 721 | 180.76.5.44 722 | 180.76.5.43 723 | 180.76.5.28 724 | 180.76.5.5 725 | 180.76.5.45 726 | 180.76.5.51 727 | 180.76.5.52 728 | 180.76.5.46 729 | 180.76.5.54 730 | 180.76.5.56 731 | 180.76.5.57 732 | 180.76.5.53 733 | 180.76.5.58 734 | 180.76.5.59 735 | 180.76.5.60 736 | 180.76.5.47 737 | 180.76.5.48 738 | 180.76.5.63 739 | 180.76.5.50 740 | 180.76.5.65 741 | 180.76.5.62 742 | 180.76.5.66 743 | 180.76.5.55 744 | 180.76.5.67 745 | 180.76.5.69 746 | 180.76.5.70 747 | 180.76.5.61 748 | 180.76.5.72 749 | 180.76.5.6 750 | 180.76.5.71 751 | 180.76.5.73 752 | 180.76.5.64 753 | 180.76.5.75 754 | 180.76.5.76 755 | 180.76.5.8 756 | 180.76.5.77 757 | 180.76.5.81 758 | 180.76.5.78 759 | 180.76.5.79 760 | 180.76.5.7 761 | 180.76.5.68 762 | 180.76.5.84 763 | 180.76.5.87 764 | 180.76.5.88 765 | 180.76.5.74 766 | 180.76.5.90 767 | 180.76.5.80 768 | 180.76.5.91 769 | 180.76.5.82 770 | 180.76.5.93 771 | 180.76.5.92 772 | 180.76.5.94 773 | 180.76.5.95 774 | 180.76.5.96 775 | 180.76.5.83 776 | 180.76.5.86 777 | 180.76.5.89 778 | 180.76.5.97 779 | 180.76.5.9 780 | 180.76.5.85 781 | 180.76.5.98 782 | 180.76.5.99 783 | 220.181.108.101 784 | 220.181.108.103 785 | 220.181.108.102 786 | 220.181.108.100 787 | 220.181.108.104 788 | 220.181.108.105 789 | 220.181.108.106 790 | 220.181.108.107 791 | 220.181.108.11 792 | 220.181.108.109 793 | 220.181.108.108 794 | 220.181.108.112 795 | 220.181.108.113 796 | 220.181.108.111 797 | 220.181.108.110 798 | 220.181.108.116 799 | 220.181.108.117 800 | 220.181.108.118 801 | 220.181.108.120 802 | 220.181.108.115 803 | 220.181.108.121 804 | 220.181.108.114 805 | 220.181.108.119 806 | 220.181.108.122 807 | 220.181.108.123 808 | 220.181.108.126 809 | 220.181.108.124 810 | 220.181.108.129 811 | 220.181.108.127 812 | 220.181.108.128 813 | 220.181.108.130 814 | 220.181.108.132 815 | 220.181.108.133 816 | 220.181.108.131 817 | 220.181.108.136 818 | 220.181.108.137 819 | 220.181.108.134 820 | 220.181.108.140 821 | 220.181.108.139 822 | 220.181.108.14 823 | 220.181.108.143 824 | 220.181.108.12 825 | 220.181.108.145 826 | 220.181.108.146 827 | 220.181.108.125 828 | 220.181.108.135 829 | 220.181.108.149 830 | 220.181.108.147 831 | 220.181.108.148 832 | 220.181.108.151 833 | 220.181.108.141 834 | 220.181.108.150 835 | 220.181.108.152 836 | 220.181.108.15 837 | 220.181.108.156 838 | 220.181.108.138 839 | 220.181.108.154 840 | 220.181.108.153 841 | 220.181.108.160 842 | 220.181.108.155 843 | 220.181.108.159 844 | 220.181.108.162 845 | 220.181.108.158 846 | 220.181.108.16 847 | 220.181.108.161 848 | 220.181.108.157 849 | 220.181.108.165 850 | 220.181.108.163 851 | 220.181.108.164 852 | 220.181.108.166 853 | 220.181.108.167 854 | 220.181.108.169 855 | 220.181.108.13 856 | 220.181.108.171 857 | 220.181.108.174 858 | 220.181.108.175 859 | 220.181.108.173 860 | 220.181.108.17 861 | 220.181.108.177 862 | 220.181.108.179 863 | 220.181.108.176 864 | 220.181.108.180 865 | 220.181.108.142 866 | 220.181.108.182 867 | 220.181.108.18 868 | 220.181.108.183 869 | 220.181.108.184 870 | 220.181.108.181 871 | 220.181.108.187 872 | 220.181.108.186 873 | 220.181.108.172 874 | 220.181.108.168 875 | 220.181.108.170 876 | 220.181.108.178 877 | 220.181.108.190 878 | 220.181.108.193 879 | 220.181.108.192 880 | 220.181.108.196 881 | 220.181.108.195 882 | 220.181.108.185 883 | 220.181.108.189 884 | 220.181.108.20 885 | 220.181.108.188 886 | 220.181.108.200 887 | 220.181.108.191 888 | 220.181.108.202 889 | 220.181.108.203 890 | 220.181.108.194 891 | 220.181.108.204 892 | 220.181.108.205 893 | 220.181.108.206 894 | 220.181.108.207 895 | 220.181.108.197 896 | 220.181.108.209 897 | 220.181.108.208 898 | 220.181.108.210 899 | 220.181.108.21 900 | 220.181.108.198 901 | 220.181.108.19 902 | 220.181.108.199 903 | 220.181.108.201 904 | 220.181.108.23 905 | 220.181.108.22 906 | 220.181.108.25 907 | 220.181.108.28 908 | 220.181.108.29 909 | 220.181.108.24 910 | 220.181.108.31 911 | 220.181.108.34 912 | 220.181.108.35 913 | 220.181.108.36 914 | 220.181.108.27 915 | 220.181.108.37 916 | 220.181.108.38 917 | 220.181.108.39 918 | 220.181.108.26 919 | 220.181.108.42 920 | 220.181.108.41 921 | 220.181.108.40 922 | 220.181.108.45 923 | 220.181.108.43 924 | 220.181.108.46 925 | 220.181.108.48 926 | 220.181.108.47 927 | 220.181.108.30 928 | 220.181.108.50 929 | 220.181.108.32 930 | 220.181.108.51 931 | 220.181.108.52 932 | 220.181.108.53 933 | 220.181.108.54 934 | 220.181.108.56 935 | 220.181.108.33 936 | 220.181.108.55 937 | 220.181.108.57 938 | 220.181.108.60 939 | 220.181.108.58 940 | 220.181.108.59 941 | 220.181.108.61 942 | 220.181.108.44 943 | 220.181.108.62 944 | 220.181.108.65 945 | 220.181.108.64 946 | 220.181.108.63 947 | 220.181.108.67 948 | 220.181.108.49 949 | 220.181.108.66 950 | 220.181.108.70 951 | 220.181.108.72 952 | 220.181.108.74 953 | 220.181.108.76 954 | 220.181.108.75 955 | 220.181.108.77 956 | 220.181.108.79 957 | 220.181.108.78 958 | 220.181.108.80 959 | 220.181.108.81 960 | 220.181.108.83 961 | 220.181.108.82 962 | 220.181.108.85 963 | 220.181.108.84 964 | 220.181.108.86 965 | 220.181.108.87 966 | 220.181.108.88 967 | 220.181.108.89 968 | 220.181.108.90 969 | 220.181.108.68 970 | 220.181.108.71 971 | 220.181.108.92 972 | 220.181.108.95 973 | 220.181.108.96 974 | 220.181.108.94 975 | 220.181.108.73 976 | 220.181.108.97 977 | 220.181.108.99 978 | 220.181.108.69 979 | 220.181.108.91 980 | 220.181.108.93 981 | 220.181.108.98 982 | 220.181.32.10 983 | 220.181.32.11 984 | 220.181.32.12 985 | 220.181.32.13 986 | 220.181.32.14 987 | 220.181.32.15 988 | 220.181.32.16 989 | 220.181.32.17 990 | 220.181.32.18 991 | 220.181.32.19 992 | 220.181.32.20 993 | 220.181.32.21 994 | 220.181.32.22 995 | 220.181.32.23 996 | 220.181.32.24 997 | 220.181.32.25 998 | 220.181.32.28 999 | 220.181.32.27 1000 | 220.181.32.26 1001 | 220.181.32.29 1002 | 220.181.32.31 1003 | 220.181.32.34 1004 | 220.181.32.35 1005 | 220.181.32.30 1006 | 220.181.32.36 1007 | 220.181.32.40 1008 | 220.181.32.41 1009 | 220.181.32.43 1010 | 220.181.32.42 1011 | 220.181.32.44 1012 | 220.181.32.45 1013 | 220.181.32.6 1014 | 220.181.32.33 1015 | 220.181.32.37 1016 | 220.181.32.39 1017 | 220.181.32.38 1018 | 220.181.32.32 1019 | 220.181.32.7 1020 | 220.181.32.8 1021 | 220.181.32.9 1022 | 61.135.165.19 1023 | 61.135.165.20 1024 | 61.135.165.53 1025 | 61.135.165.52 1026 | 61.135.168.10 1027 | 61.135.168.11 1028 | 61.135.168.12 1029 | 61.135.168.13 1030 | 61.135.168.14 1031 | 61.135.168.15 1032 | 61.135.168.16 1033 | 61.135.168.160 1034 | 61.135.168.17 1035 | 61.135.168.18 1036 | 61.135.168.19 1037 | 61.135.168.20 1038 | 61.135.168.30 1039 | 61.135.168.31 1040 | 61.135.168.32 1041 | 61.135.168.33 1042 | 61.135.168.35 1043 | 61.135.168.38 1044 | 61.135.168.39 1045 | 61.135.168.40 1046 | 61.135.168.43 1047 | 61.135.168.41 1048 | 61.135.168.37 1049 | 61.135.168.42 1050 | 61.135.168.44 1051 | 61.135.168.45 1052 | 61.135.168.46 1053 | 61.135.168.47 1054 | 61.135.168.48 1055 | 61.135.168.49 1056 | 61.135.168.50 1057 | 61.135.168.34 1058 | 61.135.168.36 1059 | 61.135.168.6 1060 | 61.135.168.7 1061 | 61.135.168.8 1062 | 61.135.168.9 1063 | 61.135.169.19 1064 | 61.135.169.20 1065 | 61.135.169.53 1066 | 61.135.169.52 1067 | 61.135.186.12 1068 | 61.135.186.13 1069 | 61.135.186.14 1070 | 61.135.186.11 1071 | 61.135.186.15 1072 | 61.135.186.16 1073 | 61.135.186.17 1074 | 61.135.186.18 1075 | 61.135.186.19 1076 | 61.135.186.20 1077 | 61.135.186.21 1078 | 61.135.186.22 1079 | 61.135.186.24 1080 | 61.135.186.25 1081 | 61.135.186.23 1082 | 61.135.186.26 1083 | 61.135.186.29 1084 | 61.135.186.30 1085 | 61.135.186.33 1086 | 61.135.186.34 1087 | 61.135.186.32 1088 | 61.135.186.27 1089 | 61.135.186.38 1090 | 61.135.186.39 1091 | 61.135.186.28 1092 | 61.135.186.40 1093 | 61.135.186.42 1094 | 61.135.186.41 1095 | 61.135.186.45 1096 | 61.135.186.43 1097 | 61.135.186.44 1098 | 61.135.186.46 1099 | 61.135.186.48 1100 | 61.135.186.31 1101 | 61.135.186.50 1102 | 61.135.186.51 1103 | 61.135.186.53 1104 | 61.135.186.55 1105 | 61.135.186.56 1106 | 61.135.186.52 1107 | 61.135.186.37 1108 | 61.135.186.36 1109 | 61.135.186.57 1110 | 61.135.186.58 1111 | 61.135.186.59 1112 | 61.135.186.35 1113 | 61.135.186.47 1114 | 61.135.186.54 1115 | 61.135.186.49 1116 | 61.135.186.60 1117 | ''' 1118 | 1119 | class SendPingThr(threading.Thread): 1120 | def __init__(self, ipPool, icmpPacket, icmpSocket, timeout=3): 1121 | threading.Thread.__init__(self) 1122 | self.Sock = icmpSocket 1123 | self.ipPool = ipPool 1124 | self.packet = icmpPacket 1125 | self.timeout = timeout 1126 | self.Sock.settimeout(timeout + 1) 1127 | 1128 | def run(self): 1129 | for ip in self.ipPool: 1130 | try: 1131 | self.Sock.sendto(self.packet, (ip, 0)) 1132 | log.debug('[-] send to %s', ip) 1133 | except socket.timeout: 1134 | break 1135 | except Exception as ex: 1136 | log.error('[!] send error : %s.', ex) 1137 | pass 1138 | time.sleep(self.timeout) 1139 | 1140 | 1141 | class Nscan: 1142 | def __init__(self, timeout=3): 1143 | self.timeout = timeout 1144 | self.__data = struct.pack('d', time.time()) 1145 | self.__id = os.getpid() 1146 | if self.__id >= 65535: self.__id = 65534 1147 | 1148 | @property 1149 | def __icmpSocket(self): 1150 | Sock = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.getprotobyname("icmp")) 1151 | return Sock 1152 | 1153 | def __inCksum(self, packet): 1154 | if len(packet) & 1: 1155 | packet = packet + '\0' 1156 | words = array.array('h', packet) 1157 | sum = 0 1158 | for word in words: 1159 | sum += (word & 0xffff) 1160 | sum = (sum >> 16) + (sum & 0xffff) 1161 | sum = sum + (sum >> 16) 1162 | return (~sum) & 0xffff 1163 | 1164 | @property 1165 | def __icmpPacket(self): 1166 | header = struct.pack('bbHHh', 8, 0, 0, self.__id, 0) 1167 | packet = header + self.__data 1168 | chkSum = self.__inCksum(packet) 1169 | header = struct.pack('bbHHh', 8, 0, chkSum, self.__id, 0) 1170 | return header + self.__data 1171 | 1172 | def mPing(self, ipPool): 1173 | Sock = self.__icmpSocket 1174 | Sock.settimeout(self.timeout) 1175 | packet = self.__icmpPacket 1176 | recvFroms = [] 1177 | sendThr = SendPingThr(ipPool, packet, Sock, self.timeout) 1178 | sendThr.start() 1179 | while True: 1180 | try: 1181 | ac_ip = Sock.recvfrom(1024)[1][0] 1182 | if ac_ip not in recvFroms: 1183 | log.debug("[*] active: %s", ac_ip) 1184 | recvFroms.append(ac_ip) 1185 | except Exception as ex: 1186 | log.error('[!] recv error : %s.', ex) 1187 | pass 1188 | finally: 1189 | if not sendThr.isAlive(): 1190 | break 1191 | return recvFroms 1192 | 1193 | 1194 | if __name__ == '__main__': 1195 | scan = Nscan() 1196 | ip_lst = iplst_txt.split() 1197 | log.info('[*] len: %s', len(ip_lst)) 1198 | res = scan.mPing(ip_lst) 1199 | log.info('[*] result len: %s', len(res)) 1200 | print(res) 1201 | --------------------------------------------------------------------------------