Nmap Development mailing list archives
[PATCH] Make new UDP-payload code reusable.
From: "Luis M." <luis.mgarc () gmail com>
Date: Tue, 07 Jul 2009 18:02:30 +0200
Hi! I've been having a look at David's new UDP-payload code and I've seen that it depends on the NmapOps class so the code is not reusable by other apps. The thing is that at some point I would like to include that functionality to nping. For that, the best thing would be to move UDP-payload-related code to nbase (same thing Fyodor and I are planning to do with many other functions that nmap and nping share). So the thing is that function get_udp_payload() has this: const char *get_udp_payload(u16 dport, size_t *length) { const char *payload; if (o.extra_payload_length > 0) { *length = o.extra_payload_length; return o.extra_payload; } In my opinion, it should be the caller's responsibility to ensure that the user has not specified a custom payload. I've checked which parts of nmap actually call get_udp_payload() and I've found that only sendIPScanProbe() uses it. Moving that if sentence to sendIPScanProbe() is trivial and should make get_udp_payload() reusable by other apps so we can move it to nbase at some point. I attach a patch that does this. Please let me know what you think. Is there any important disadvantage to my approach? Regards, Luis.
Index: scan_engine.cc =================================================================== --- scan_engine.cc (revision 14088) +++ scan_engine.cc (working copy) @@ -3089,9 +3089,15 @@ } else if (pspec->type == PS_UDP) { const char *payload; size_t payload_length; - - payload = get_udp_payload(pspec->pd.udp.dport, &payload_length); - + + /* If user requested a specific payload, use it. Otherwise use our own + * UDP payload (the scan may get better results this way) */ + if (o.extra_payload_length > 0) { + payload_length = o.extra_payload_length; + payload = o.extra_payload; + }else{ + payload = get_udp_payload(pspec->pd.udp.dport, &payload_length); + } for(decoy = 0; decoy < o.numdecoys; decoy++) { packet = build_udp_raw(&o.decoys[decoy], hss->target->v4hostip(), o.ttl, ipid, IP_TOS_DEFAULT, false, Index: payload.cc =================================================================== --- payload.cc (revision 14088) +++ payload.cc (working copy) @@ -138,11 +138,6 @@ const char *get_udp_payload(u16 dport, size_t *length) { const char *payload; - if (o.extra_payload_length > 0) { - *length = o.extra_payload_length; - return o.extra_payload; - } - #define SET_PAYLOAD(p) do { *length = sizeof(p) - 1; payload = (p); } while (0) switch (dport) {
_______________________________________________ Sent through the nmap-dev mailing list http://cgi.insecure.org/mailman/listinfo/nmap-dev Archived at http://SecLists.Org
Current thread:
- [PATCH] Make new UDP-payload code reusable. Luis M. (Jul 07)
- Re: [PATCH] Make new UDP-payload code reusable. David Fifield (Jul 07)
- Re: [PATCH] Make new UDP-payload code reusable. Luis M. (Jul 07)
- Re: [PATCH] Make new UDP-payload code reusable. David Fifield (Jul 07)
- Re: [PATCH] Make new UDP-payload code reusable. Luis M. (Jul 07)
- Re: [PATCH] Make new UDP-payload code reusable. Fyodor (Jul 07)
- Re: [PATCH] Make new UDP-payload code reusable. David Fifield (Jul 07)