MCPcopy Index your code
hub / github.com/secdev/scapy / nmap_sig

Function nmap_sig

scapy/modules/nmap.py:157–186  ·  view source on GitHub ↗
(target, oport=80, cport=81, ucport=1)

Source from the content-addressed store, hash-verified

155
156
157def nmap_sig(target, oport=80, cport=81, ucport=1):
158 # type: (str, int, int, int) -> Dict
159 res = {}
160
161 tcpopt = [("WScale", 10),
162 ("NOP", None),
163 ("MSS", 256),
164 ("Timestamp", (123, 0))]
165 tests = [
166 IP(dst=target, id=1) /
167 TCP(seq=1, sport=5001 + i, dport=oport if i < 4 else cport,
168 options=tcpopt, flags=flags)
169 for i, flags in enumerate(["CS", "", "SFUP", "A", "S", "A", "FPU"])
170 ]
171 tests.append(IP(dst=target) / UDP(sport=5008, dport=ucport) / (300 * "i"))
172
173 ans, unans = sr(tests, timeout=2)
174 ans.extend((x, None) for x in unans)
175
176 for snd, rcv in ans:
177 if snd.sport == 5008:
178 res["PU"] = (snd, rcv)
179 else:
180 test = "T%i" % (snd.sport - 5000)
181 if rcv is not None and ICMP in rcv:
182 warning("Test %s answered by an ICMP", test)
183 rcv = None # type: ignore
184 res[test] = rcv
185
186 return nmap_probes2sig(res)
187
188
189def nmap_probes2sig(tests):

Callers 1

nmap_fpFunction · 0.85

Calls 8

IPClass · 0.90
TCPClass · 0.90
UDPClass · 0.90
srFunction · 0.90
warningFunction · 0.90
nmap_probes2sigFunction · 0.85
extendMethod · 0.80
appendMethod · 0.45

Tested by

no test coverage detected