6
6
import logging
7
7
import os
8
8
import sys
9
- import corpus
10
- from corpus_curl_opt_http_auth import CurlOptHttpAuth
9
+
10
+ from curl_fuzzer_tools .corpus import TLVEncoder
11
+ from curl_fuzzer_tools .corpus_curl_opt_http_auth import CurlOptHttpAuth
12
+ from curl_fuzzer_tools .curl_test_data import TestData
13
+
11
14
log = logging .getLogger (__name__ )
12
15
13
16
14
17
def generate_corpus (options ):
15
18
sys .path .append (options .curl_test_dir )
16
- import curl_test_data
17
19
18
- td = curl_test_data .TestData (os .path .join (options .curl_test_dir ,
19
- "data" ))
20
+ td = TestData (os .path .join (options .curl_test_dir , "data" ))
20
21
21
22
with open (options .output , "wb" ) as f :
22
- enc = corpus . TLVEncoder (f , td )
23
+ enc = TLVEncoder (f , td )
23
24
24
25
# Write the URL to the file.
25
26
enc .write_string (enc .TYPE_URL , options .url )
26
27
27
28
# Write any responses to the file.
28
- enc .maybe_write_response (enc .TYPE_RSP0 , options .rsp0 , options .rsp0file , options .rsp0test )
29
- enc .maybe_write_response (enc .TYPE_RSP1 , options .rsp1 , options .rsp1file , options .rsp1test )
30
- enc .maybe_write_response (enc .TYPE_RSP2 , options .rsp2 , options .rsp2file , options .rsp2test )
31
- enc .maybe_write_response (enc .TYPE_RSP3 , options .rsp3 , options .rsp3file , options .rsp3test )
32
- enc .maybe_write_response (enc .TYPE_RSP4 , options .rsp4 , options .rsp4file , options .rsp4test )
33
- enc .maybe_write_response (enc .TYPE_RSP5 , options .rsp5 , options .rsp5file , options .rsp5test )
34
- enc .maybe_write_response (enc .TYPE_RSP6 , options .rsp6 , options .rsp6file , options .rsp6test )
35
- enc .maybe_write_response (enc .TYPE_RSP7 , options .rsp7 , options .rsp7file , options .rsp7test )
36
- enc .maybe_write_response (enc .TYPE_RSP8 , options .rsp8 , options .rsp8file , options .rsp8test )
37
- enc .maybe_write_response (enc .TYPE_RSP9 , options .rsp9 , options .rsp9file , options .rsp9test )
38
- enc .maybe_write_response (enc .TYPE_RSP10 , options .rsp10 , options .rsp10file , options .rsp10test )
29
+ enc .maybe_write_response (
30
+ enc .TYPE_RSP0 , options .rsp0 , options .rsp0file , options .rsp0test
31
+ )
32
+ enc .maybe_write_response (
33
+ enc .TYPE_RSP1 , options .rsp1 , options .rsp1file , options .rsp1test
34
+ )
35
+ enc .maybe_write_response (
36
+ enc .TYPE_RSP2 , options .rsp2 , options .rsp2file , options .rsp2test
37
+ )
38
+ enc .maybe_write_response (
39
+ enc .TYPE_RSP3 , options .rsp3 , options .rsp3file , options .rsp3test
40
+ )
41
+ enc .maybe_write_response (
42
+ enc .TYPE_RSP4 , options .rsp4 , options .rsp4file , options .rsp4test
43
+ )
44
+ enc .maybe_write_response (
45
+ enc .TYPE_RSP5 , options .rsp5 , options .rsp5file , options .rsp5test
46
+ )
47
+ enc .maybe_write_response (
48
+ enc .TYPE_RSP6 , options .rsp6 , options .rsp6file , options .rsp6test
49
+ )
50
+ enc .maybe_write_response (
51
+ enc .TYPE_RSP7 , options .rsp7 , options .rsp7file , options .rsp7test
52
+ )
53
+ enc .maybe_write_response (
54
+ enc .TYPE_RSP8 , options .rsp8 , options .rsp8file , options .rsp8test
55
+ )
56
+ enc .maybe_write_response (
57
+ enc .TYPE_RSP9 , options .rsp9 , options .rsp9file , options .rsp9test
58
+ )
59
+ enc .maybe_write_response (
60
+ enc .TYPE_RSP10 , options .rsp10 , options .rsp10file , options .rsp10test
61
+ )
39
62
40
63
# Write any second socket responses to the file.
41
- enc .maybe_write_response (enc .TYPE_SECRSP0 , options .secrsp0 , options .secrsp0file , options .secrsp0test )
42
- enc .maybe_write_response (enc .TYPE_SECRSP1 , options .secrsp1 , options .secrsp1file , options .secrsp1test )
64
+ enc .maybe_write_response (
65
+ enc .TYPE_SECRSP0 , options .secrsp0 , options .secrsp0file , options .secrsp0test
66
+ )
67
+ enc .maybe_write_response (
68
+ enc .TYPE_SECRSP1 , options .secrsp1 , options .secrsp1file , options .secrsp1test
69
+ )
43
70
44
71
# Write other options to file.
45
72
enc .maybe_write_string (enc .TYPE_USERNAME , options .username )
@@ -59,7 +86,9 @@ def generate_corpus(options):
59
86
enc .maybe_write_string (enc .TYPE_XOAUTH2_BEARER , options .bearertoken )
60
87
enc .maybe_write_string (enc .TYPE_USERPWD , options .user_and_pass )
61
88
enc .maybe_write_string (enc .TYPE_USERAGENT , options .useragent )
62
- enc .maybe_write_string (enc .TYPE_SSH_HOST_PUBLIC_KEY_SHA256 , options .hostpksha256 )
89
+ enc .maybe_write_string (
90
+ enc .TYPE_SSH_HOST_PUBLIC_KEY_SHA256 , options .hostpksha256
91
+ )
63
92
enc .maybe_write_string (enc .TYPE_HSTS , options .hsts )
64
93
65
94
enc .maybe_write_u32 (enc .TYPE_OPTHEADER , options .optheader )
@@ -75,8 +104,10 @@ def generate_corpus(options):
75
104
if options .httpauth :
76
105
# translate a string HTTP auth name to an unsigned long bitmask
77
106
# value in the format CURLOPT_HTTPAUTH expects
78
- log .debug (f"Mapping provided CURLOPT_HTTPAUTH='{ options .httpauth } ' "
79
- f"to { CurlOptHttpAuth [options .httpauth ].value } L (ulong)" )
107
+ log .debug (
108
+ f"Mapping provided CURLOPT_HTTPAUTH='{ options .httpauth } ' "
109
+ f"to { CurlOptHttpAuth [options .httpauth ].value } L (ulong)"
110
+ )
80
111
http_auth_value = CurlOptHttpAuth [options .httpauth ].value
81
112
enc .maybe_write_u32 (enc .TYPE_HTTPAUTH , http_auth_value )
82
113
@@ -150,9 +181,9 @@ def get_options():
150
181
parser .add_argument ("--useragent" , type = str )
151
182
parser .add_argument ("--netrclevel" , type = int )
152
183
parser .add_argument ("--hostpksha256" , type = str )
153
- parser .add_argument ("--wsoptions" , action = ' store_true' )
184
+ parser .add_argument ("--wsoptions" , action = " store_true" )
154
185
parser .add_argument ("--connectonly" , type = int )
155
- parser .add_argument ("--post" , action = ' store_true' )
186
+ parser .add_argument ("--post" , action = " store_true" )
156
187
parser .add_argument ("--hsts" )
157
188
158
189
upload1 = parser .add_mutually_exclusive_group ()
@@ -189,6 +220,7 @@ def setup_logging():
189
220
190
221
class ScriptRC (object ):
191
222
"""Enum for script return codes"""
223
+
192
224
SUCCESS = 0
193
225
FAILURE = 1
194
226
EXCEPTION = 2
@@ -215,5 +247,5 @@ def main():
215
247
return rc
216
248
217
249
218
- if __name__ == ' __main__' :
250
+ if __name__ == " __main__" :
219
251
sys .exit (main ())
0 commit comments