@@ -160,6 +160,9 @@ static u8 var_bytes[MAP_SIZE]; /* Bytes that appear to be variable */
160
160
161
161
static s32 shm_id ; /* ID of the SHM region */
162
162
163
+ //unsigned int* extract_response_codes_generic(unsigned char* buf, unsigned int buf_size, unsigned int* state_count_ref);
164
+
165
+ region_t * extract_requests_generic (unsigned char * buf , unsigned int buf_size , unsigned int * region_count_ref );
163
166
static volatile u8 stop_soon , /* Ctrl-C pressed? */
164
167
clear_screen = 1 , /* Window resized? */
165
168
child_timed_out ; /* Traced process timed out? */
@@ -394,12 +397,12 @@ u8 state_selection_algo = ROUND_ROBIN, seed_selection_algo = RANDOM_SELECTION;
394
397
u8 false_negative_reduction = 0 ;
395
398
396
399
/* Implemented state machine */
397
- Agraph_t * ipsm ;
398
- static FILE * ipsm_dot_file ;
400
+ // Agraph_t *ipsm;
401
+ // static FILE* ipsm_dot_file;
399
402
400
403
/* Hash table/map and list */
401
404
klist_t (lms ) * kl_messages ;
402
- khash_t (hs32 ) * khs_ipsm_paths ;
405
+ // khash_t(hs32) *khs_ipsm_paths;
403
406
khash_t (hms ) * khms_states ;
404
407
405
408
//M2_prev points to the last message of M1 (i.e., prefix)
@@ -409,18 +412,18 @@ khash_t(hms) *khms_states;
409
412
kliter_t (lms ) * M2_prev , * M2_next ;
410
413
411
414
//Function pointers pointing to Protocol-specific functions
412
- unsigned int * (* extract_response_codes )(unsigned char * buf , unsigned int buf_size , unsigned int * state_count_ref ) = NULL ;
413
- region_t * (* extract_requests )(unsigned char * buf , unsigned int buf_size , unsigned int * region_count_ref ) = NULL ;
415
+ // unsigned int* (*extract_response_codes)(unsigned char* buf, unsigned int buf_size, unsigned int* state_count_ref) = extract_response_codes_generic ;
416
+ region_t * (* extract_requests )(unsigned char * buf , unsigned int buf_size , unsigned int * region_count_ref ) = extract_requests_generic ;
414
417
415
418
/* Initialize the implemented state machine as a graphviz graph */
416
419
void setup_ipsm ()
417
420
{
418
- ipsm = agopen ("g" , Agdirected , 0 );
421
+ // ipsm = agopen("g", Agdirected, 0);
419
422
420
- agattr (ipsm , AGNODE , "color" , "black" ); //Default node colr is black
421
- agattr (ipsm , AGEDGE , "color" , "black" ); //Default edge color is black
423
+ // agattr(ipsm, AGNODE, "color", "black"); //Default node colr is black
424
+ // agattr(ipsm, AGEDGE, "color", "black"); //Default edge color is black
422
425
423
- khs_ipsm_paths = kh_init (hs32 );
426
+ // khs_ipsm_paths = kh_init(hs32);
424
427
425
428
khms_states = kh_init (hms );
426
429
}
@@ -517,21 +520,21 @@ u8 is_state_sequence_interesting(unsigned int *state_sequence, unsigned int stat
517
520
}
518
521
519
522
/* Update the annotations of regions (i.e., state sequence received from the server) */
520
- void update_region_annotations (struct queue_entry * q )
521
- {
522
- u32 i = 0 ;
523
-
524
- for (i = 0 ; i < messages_sent ; i ++ ) {
525
- if ((response_bytes [i ] == 0 ) || ( i > 0 && (response_bytes [i ] - response_bytes [i - 1 ] == 0 ))) {
526
- q -> regions [i ].state_sequence = NULL ;
527
- q -> regions [i ].state_count = 0 ;
528
- } else {
529
- unsigned int state_count ;
530
- q -> regions [i ].state_sequence = (* extract_response_codes )(response_buf , response_bytes [i ], & state_count );
531
- q -> regions [i ].state_count = state_count ;
532
- }
533
- }
534
- }
523
+ // void update_region_annotations(struct queue_entry* q)
524
+ // {
525
+ // u32 i = 0;
526
+ //
527
+ // for (i = 0; i < messages_sent; i++) {
528
+ // if ((response_bytes[i] == 0) || ( i > 0 && (response_bytes[i] - response_bytes[i - 1] == 0))) {
529
+ // q->regions[i].state_sequence = NULL;
530
+ // q->regions[i].state_count = 0;
531
+ // } else {
532
+ // unsigned int state_count;
533
+ // q->regions[i].state_sequence = (*extract_response_codes)(response_buf, response_bytes[i], &state_count);
534
+ // q->regions[i].state_count = state_count;
535
+ // }
536
+ // }
537
+ // }
535
538
536
539
/* Choose a region data for region-level mutations */
537
540
u8 * choose_source_region (u32 * out_len ) {
@@ -2231,6 +2234,83 @@ EXP_ST void setup_shm(void) {
2231
2234
}
2232
2235
2233
2236
2237
+
2238
+
2239
+ /********************************************************/
2240
+ /* StateAFL bypasses response code extraction */
2241
+ /* and build a generic request extraction */
2242
+ unsigned int * extract_response_codes_generic (unsigned char * buf , unsigned int buf_size , unsigned int * state_count_ref ) {
2243
+
2244
+ unsigned int state_tracer_count_all = state_shared_ptr -> seq_len ;
2245
+
2246
+ * state_count_ref = state_tracer_count_all ;
2247
+
2248
+ unsigned int * state_sequence = ck_alloc ( (* state_count_ref )* sizeof (int ) );
2249
+ memcpy (state_sequence , state_shared_ptr -> seq , * state_count_ref * sizeof (unsigned int ));
2250
+
2251
+
2252
+ return state_sequence ;
2253
+ }
2254
+
2255
+ //static unsigned int mutated_region_count = 0;
2256
+ //static region_t* mutated_regions = NULL;
2257
+
2258
+ region_t * extract_requests_generic (unsigned char * buf , unsigned int buf_size , unsigned int * region_count_ref ) {
2259
+
2260
+ unsigned int region_count = 0 ;
2261
+ region_t * regions = NULL ;
2262
+
2263
+ unsigned int cur_start = 0 ;
2264
+
2265
+ //if(mutated_regions != NULL && mutated_region_count > 0) {
2266
+
2267
+ // *region_count_ref = mutated_region_count;
2268
+
2269
+ // regions = ck_alloc(mutated_region_count * sizeof(region_t));
2270
+ // memcpy(regions, mutated_regions, mutated_region_count * sizeof(region_t));
2271
+
2272
+ // return regions;
2273
+ //}
2274
+
2275
+
2276
+ unsigned int byte_count = 0 ;
2277
+
2278
+ while (byte_count < buf_size ) {
2279
+
2280
+ if (byte_count + 4 >= buf_size ) {
2281
+ PFATAL ("AFLNet - Erroreous message length in input file" );
2282
+ }
2283
+
2284
+ unsigned int next_message_len = * ((unsigned int * )(void * )& buf [byte_count ]);
2285
+
2286
+ byte_count += sizeof (unsigned int );
2287
+
2288
+ if (byte_count + next_message_len > buf_size ) {
2289
+ PFATAL ("AFLNet - Erroneous message length in input file (2)" );
2290
+ }
2291
+
2292
+ region_count ++ ;
2293
+
2294
+ regions = (region_t * )ck_realloc (regions , region_count * sizeof (region_t ));
2295
+
2296
+ regions [region_count - 1 ].start_byte = cur_start ;
2297
+ regions [region_count - 1 ].end_byte = cur_start + next_message_len - 1 ;
2298
+ regions [region_count - 1 ].state_sequence = NULL ;
2299
+ regions [region_count - 1 ].state_count = 0 ;
2300
+
2301
+ cur_start += next_message_len ;
2302
+ byte_count += next_message_len ;
2303
+
2304
+ }
2305
+
2306
+ * region_count_ref = region_count ;
2307
+ return regions ;
2308
+
2309
+ }
2310
+ /* End of StateAFL */
2311
+ /********************************************************/
2312
+
2313
+
2234
2314
/* Load postprocessor, if available. */
2235
2315
2236
2316
static void setup_post (void ) {
@@ -9074,6 +9154,11 @@ int main(int argc, char** argv) {
9074
9154
FATAL ("%s protocol is not supported yet!" , optarg );
9075
9155
}
9076
9156
9157
+
9158
+ // bypass the protocol selection
9159
+ extract_requests = & extract_requests_generic ;
9160
+ extract_response_codes = & extract_response_codes_generic ;
9161
+
9077
9162
protocol_selected = 1 ;
9078
9163
9079
9164
break ;
@@ -9132,7 +9217,7 @@ int main(int argc, char** argv) {
9132
9217
//AFLNet - Check for required arguments
9133
9218
if (!use_net ) FATAL ("Please specify network information of the server under test (e.g., tcp://127.0.0.1/8554)" );
9134
9219
9135
- if (!protocol_selected ) FATAL ("Please specify the protocol to be tested using the -P option" );
9220
+ // if (!protocol_selected) FATAL("Please specify the protocol to be tested using the -P option");
9136
9221
9137
9222
if (netns_name ) {
9138
9223
if (check_ep_capability (CAP_SYS_ADMIN , argv [0 ]) != 0 )
0 commit comments