52 Commits

Author SHA1 Message Date
Martin Gallo cd4fe47cfc Arrange tagline, copyright and license notes across all source files
This was a pending change to:
- Use the same tagline, copyright and license notice across files.
- Remove authors' contacts that are no longer valid (due to affiliation changes).
- Update repository location.
- Update license file with missing licenses (althought those were already in source files).

This doesn't include any change on the source code, nor any change on current copyright or licenses. Just formatting and phrasing to make our and distro's maintainers life easier.
2021-07-20 10:04:27 -03:00
Martin Gallo 976d39a14a Attempt to fix Python 3.9 compatibility issue with array.array tostring/fromstring methods (#1054)
Python 3.9 removed the `array.array` `tostring` and `fromstring` methods (see https://docs.python.org/3/whatsnew/3.9.html#removed).
Note that the `tostring` and `fromstring` methods were already deprecated since Python 3.2, but aliases to the new `tobytes` and `frombytes` were provided (see https://docs.python.org/3/library/array.html#array.array.tobytes).

This:
- Adds helper function to use `tostring` and `fromstring` in Python <3.2 versions and `tobytes` and `frombytes` in Python>=3.2.
- Replaces uses of `tostring` and `fromstring` with the new helper function.
2021-04-19 14:57:43 -03:00
asolino ec77ea3d06 Code cleanup homework
- Optimizing imports
- Removing unused variables
- Still a lot to do.
- Test cases passing OK
2018-12-04 14:47:16 -03:00
cclauss 80506c1620 Fix more Python 3 issues 2018-11-24 00:06:49 +01:00
cclauss 781178227a Use print() function in both Python 2 and Python 3 2018-11-23 19:25:59 +01:00
luz.paz 0e96b60b92 Misc. typos
Found via `codespell -q 3 -I ../impacket-word-whitelist.txt` through downstream `curl`
2018-03-16 09:42:21 -04:00
Michal Ambroz c39c942a51 Moving os_ident to impacket.examples 2018-03-11 12:57:54 +01:00
Martin Gallo 4152e128b8 Replaced shebang with a virtualenv friendly one
Replaced all instances of `#!/usr/bin/python` with `#!/usr/bin/env python` so impacket's examples and scripts can be run inside a virtualenv without having to call python.
2017-01-11 12:43:54 -03:00
asolino 8c094b7998 Adding eXecute permissions to the scripts, fixing https://github.com/CoreSecurity/impacket/issues/71 2015-06-25 09:50:19 -03:00
asolino 4e32a0d498 Removing some pyCharm's erros/warnings
More scripts/libs changed. Hopefully doesn't break a thing. Test cases are passing
2015-05-25 20:40:17 -03:00
asolino 119e4438dd Changing logging mechanisms everywhere.
Full details coming soon
2015-04-25 14:40:41 -03:00
gera@corest.com 80469292e1 reordered ECN responder, and added some debug prints (commented out) 2009-06-08 20:08:29 +00:00
gera@corest.com 7cdfaebd08 added --help parameter 2009-06-08 19:13:09 +00:00
gera 2c74f0520b added fault nmapOSDB pointing to /usr/share/nmap/nmap-os-db 2009-05-12 22:39:54 +00:00
gera 1b3d460715 added command line argument -d to specify the nmap-os-db file 2009-05-07 16:11:13 +00:00
gera 934278323f some refactoring, and added udp cmd packets, can be used like:
echo cmd:exit | nc -u 192.168.66.254 12345
2009-05-06 15:30:12 +00:00
gera 2befae7503 no real changes` 2009-04-29 16:27:29 +00:00
gera 41847ccf70 added impact compatibility 2009-04-23 20:43:13 +00:00
gera fffd897ec7 fixed ClosedTCPResponder and added it to the list of responders
initial seq number for TCPResponders is now according to the generator
2009-04-23 20:02:50 +00:00
gera 1704aedb56 # [x] TCP RST data checksum (RD)
I forgot this test before, now we are really done
2009-04-20 21:17:19 +00:00
gera 21fde00a30 # U1()
# [x] Responsiveness (R)
# [x] IP don't fragment bit (DF)
# [x] IP initial time-to-live (T)
# [x] IP initial time-to-live guess (TG)
# [x] IP total length (IPL)
# [x] Unused port unreachable field nonzero (UN)
# [x] Returned probe IP total length value (RIPL)
# [x] Returned probe IP ID value (RID)
# [x] Integrity of returned probe IP checksum value (RIPCK)
# [x] Integrity of returned probe UDP checksum (RUCK)
# [x] Integrity of returned UDP data (RUD)
# [-] ??? (TOS) Type of Service
# [-] ??? (RUL) Length of return UDP packet is correct

and we are done!
2009-04-16 20:28:59 +00:00
gera c32a707b48 modified a little bit how default options are handlded 2009-04-16 20:23:49 +00:00
gera ed262c2499 # U1()
# [x] Responsiveness (R)
# [x] IP don't fragment bit (DF)
# [x] IP initial time-to-live (T)
# [x] IP initial time-to-live guess (TG)
# [x] IP total length (IPL)
# [x] Unused port unreachable field nonzero (UN)
# [x] Returned probe IP total length value (RIPL)
# [x] Returned probe IP ID value (RID)
# [x] Integrity of returned probe IP checksum value (RIPCK)
# [x] Integrity of returned probe UDP checksum (RUCK)
# [ ] Integrity of returned UDP data (RUD)
# [-] ??? (TOS) Type of Service
# [-] ??? (RUL) Length of return UDP packet is correct
2009-04-16 20:23:02 +00:00
gera dae8dc625f # U1()
# [x] Responsiveness (R)
# [x] IP don't fragment bit (DF)
# [x] IP initial time-to-live (T)
# [x] IP initial time-to-live guess (TG)
# [x] IP total length (IPL)
# [x] Unused port unreachable field nonzero (UN)
# [x] Returned probe IP total length value (RIPL)
# [x] Returned probe IP ID value (RID)
# [x] Integrity of returned probe IP checksum value (RIPCK)
# [ ] Integrity of returned probe UDP checksum (RUCK)
# [ ] Integrity of returned UDP data (RUD)
# [-] ??? (TOS) Type of Service
# [-] ??? (RUL) Length of return UDP packet is correct
2009-04-16 20:18:52 +00:00
gera 1f06a05721 # U1()
# [x] Responsiveness (R)
# [x] IP don't fragment bit (DF)
# [x] IP initial time-to-live (T)
# [x] IP initial time-to-live guess (TG)
# [x] IP total length (IPL)
# [x] Unused port unreachable field nonzero (UN)
# [x] Returned probe IP total length value (RIPL)
# [x] Returned probe IP ID value (RID)
# [ ] Integrity of returned probe IP checksum value (RIPCK)
# [ ] Integrity of returned probe UDP checksum (RUCK)
# [ ] Integrity of returned UDP data (RUD)
# [-] ??? (TOS) Type of Service
# [-] ??? (RUL) Length of return UDP packet is correct
2009-04-16 20:05:23 +00:00
gera f51f3777f9 # U1()
# [x] Responsiveness (R)
# [x] IP don't fragment bit (DF)
# [x] IP initial time-to-live (T)
# [x] IP initial time-to-live guess (TG)
# [x] IP total length (IPL)
# [x] Unused port unreachable field nonzero (UN)
# [x] Returned probe IP total length value (RIPL)
# [ ] Returned probe IP ID value (RID)
# [ ] Integrity of returned probe IP checksum value (RIPCK)
# [ ] Integrity of returned probe UDP checksum (RUCK)
# [ ] Integrity of returned UDP data (RUD)
# [-] ??? (TOS) Type of Service
# [-] ??? (RUL) Length of return UDP packet is correct
2009-04-16 20:03:31 +00:00
gera 291fdb9ca7 # U1()
# [x] Responsiveness (R)
# [x] IP don't fragment bit (DF)
# [x] IP initial time-to-live (T)
# [x] IP initial time-to-live guess (TG)
# [x] IP total length (IPL)
# [x] Unused port unreachable field nonzero (UN)
# [ ] Returned probe IP total length value (RIPL)
# [ ] Returned probe IP ID value (RID)
# [ ] Integrity of returned probe IP checksum value (RIPCK)
# [ ] Integrity of returned probe UDP checksum (RUCK)
# [ ] Integrity of returned UDP data (RUD)
# [-] ??? (TOS) Type of Service
# [-] ??? (RUL) Length of return UDP packet is correct
2009-04-16 20:00:24 +00:00
gera e1b8d77449 # U1()
# [x] Responsiveness (R)
# [x] IP don't fragment bit (DF)
# [x] IP initial time-to-live (T)
# [x] IP initial time-to-live guess (TG)
# [x] IP total length (IPL)
# [ ] Unused port unreachable field nonzero (UN)
# [ ] Returned probe IP total length value (RIPL)
# [ ] Returned probe IP ID value (RID)
# [ ] Integrity of returned probe IP checksum value (RIPCK)
# [ ] Integrity of returned probe UDP checksum (RUCK)
# [ ] Integrity of returned UDP data (RUD)
# [-] ??? (TOS) Type of Service
# [-] ??? (RUL) Length of return UDP packet is correct
2009-04-16 19:52:31 +00:00
gera 0b62023ac0 # U1()
# [x] Responsiveness (R)
# [x] IP don't fragment bit (DF)
# [x] IP initial time-to-live (T)
# [x] IP initial time-to-live guess (TG)
# [ ] IP total length (IPL)
# [ ] Unused port unreachable field nonzero (UN)
# [ ] Returned probe IP total length value (RIPL)
# [ ] Returned probe IP ID value (RID)
# [ ] Integrity of returned probe IP checksum value (RIPCK)
# [ ] Integrity of returned probe UDP checksum (RUCK)
# [ ] Integrity of returned UDP data (RUD)
# [-] ??? (TOS) Type of Service
# [-] ??? (RUL) Length of return UDP packet is correct
2009-04-16 19:35:16 +00:00
gera f32434874b first tests on NMAP2UDPResponder
# U1()
# [x] Responsiveness (R)
# [x] IP don't fragment bit (DF)
# [x] IP initial time-to-live (T)
2009-04-16 19:34:48 +00:00
gera 8dabad50e2 added UDPResponder, ClosedUDPResponder and OpenUDPResponder... all working :) 2009-04-16 18:58:48 +00:00
gera 3eca8d639a initAnswer() --> buildAnswer() 2009-04-16 18:43:29 +00:00
gera 497d95c90b refactored a little bit:
moved initAnswer() to the top class (Responder) and
    added the logic to initAnswer() -> sendPacket() to Responder.process()

    The open ports are now a list of ports, and only Machine knows about it
    Closed ports are not listed, are those not open
2009-04-16 18:36:05 +00:00
gera 1295ddabec marked a few more things done (they were done before, just not marked) 2009-04-15 23:18:07 +00:00
gera 832d3466ed not randomizing the delta for stdDev 2009-04-15 22:59:28 +00:00
gera e5e6103094 # [x] IP ID sequence generation algorithm on ICMP messages (II)
# [x] Shared IP ID sequence Boolean (SS)
2009-04-15 22:52:11 +00:00
gera c5efeea375 # [x] IP Type of Service (TOSI) 2009-04-15 22:28:16 +00:00
gera f34a8edbc5 # [x] ICMP response code (CD) 2009-04-15 22:19:49 +00:00
gera 7b9e924827 # [x] ICMP Sequence number (SI) 2009-04-15 22:08:38 +00:00
gera 23fba4a4d8 some safe checking on unsupported on IE(DFI) and IE(DLI)
we should do this on every other option
2009-04-15 22:01:52 +00:00
gera bc9521c8df +# [x] IP Data Length (DLI) 2009-04-15 21:53:23 +00:00
gera d95ae313fd # IE()
# [x] Responsiveness (R)
# [x] Don't fragment (ICMP) (DFI)
# [x] IP initial time-to-live (T)
# [x] IP initial time-to-live guess (TG)
2009-04-15 21:49:00 +00:00
gera 31c0a58064 Improved a lot GCD, ISR and SP emulation!!!
thanks to talking to aureliano we realized that if sequence numbers are
generated on Timer events, then, the numbers are incremented only at this events
and it doesn't matter how close we are sampling to the event, so we don't have
to roung to the closes integer, but rather truncate to the previous
2009-04-15 21:45:27 +00:00
gera 383e915315 +# [x] IP ID sequence generation algorithm (TI)
+#   [x] Z  - All zeros
+#   [x] RD - Random: It increments at least once by at least 20000.
+#   [x] RI - Random positive increments. Any (delta_i > 1000, and delta_i % 256 != 0) or (delta_i > 256000 and delta_i % 256 == 0)
2009-04-15 19:40:31 +00:00
gera 5d8ea44b72 fixed initial window size. it was fixed 0, and then, it was not hex encoeded 2009-04-15 19:39:37 +00:00
gera 6461e0937f removed some void __init__()s
bugfix: making a copy of the fingerprint from the machine, otherwise subsequent changes affect all references to the fingerprint (all SEQn where sharing and changing the same fingerprint)
changed how test SP (stdDev) is computed and used. Now we are trying adding a random value
2009-04-15 19:29:08 +00:00
gera fc404cbd26 # [ ] IP ID sequence generation algorithm (TI)
+#   [+] Z  - All zeros
 +#   [+] RD - Random: It increments at least once by at least 20000.
 +#   [-] Hex Value - fixed IP ID
 +#   [+] RI - Random positive increments. Any (delta_i > 1000, and delta_i % 256 != 0) or (delta_i > 256000 and delta_i % 256 == 0)
 +#   [x] BI - Broken increment. All delta_i % 256 = 0 and all delta_i <= 5120.
 +#   [x] I - Incremental. All delta_i < 10
 +#   [x] O - (Ommited, the test does not show in the fingerprint). None of the other

I also added simplifyFinerprints() which simplifies them by leaving only the first option when there are more than one (separated by | in the fingerprint file)
2009-04-15 16:43:44 +00:00
gera 81e730b941 a few bugs introduced in the latest commit 2009-04-15 15:52:27 +00:00
gera cf55eb8068 # All Probes
+# [|] SEQ
+# [x] OPS
+# [x] WIN

 # All Tests
 
 # SEQ()
+# [x] TCP ISN sequence predictability index (SP)
+# [x] TCP ISN greatest common divisor (GCD)
+# [x] TCP ISN counter rate (ISR)
 # [ ] IP ID sequence generation algorithm (TI)
+#   [ ] Z  - All zeros
+#   [ ] RD - Random: It increments at least once by at least 20000.
+#   [ ] Hex Value - fixed IP ID
+#   [ ] RI - Random positive increments. Any (delta_i > 1000, and delta_i % 256 != 0) or (delta_i > 256000 and delta_i % 256 == 0)
+#   [ ] BI - Broken increment. All delta_i % 256 = 0 and all delta_i <= 5120.
+#   [ ] I - Incremental. All delta_i < 10
+#   [ ] O - (Ommited, the test does not show in the fingerprint). None of the other
+# [x] TCP timestamp option algorithm (TS)
+#   [x] U - unsupported (don't send TS)
+#   [x] 0 - Zero
+#   [x] 1 - 0-5.66 (2 Hz)
+#   [x] 7 - 70-150 (100 Hz)
+#   [x] 8 - 150-350 (200 Hz)
+#   [x]   - avg_freq = sum(TS_diff/time_diff) . round(.5 + math.log(avg_freq)/math.log(2)))
+#           time_diff = 0.11 segs
 # OPS()
+# [x] TCP options (O, O1-O6)
 # WIN()
+# [x] TCP initial window size (W, W1-W6)
 # ECN, T1-T7
+# [x] TCP options (O, O1-O6)
+# [x] TCP initial window size (W, W1-W6)
+# [ ] IP Type of Service (TOSI)
+# [ ] ICMP Sequence number (SI)
+# [ ] IP Data Length (DLI)
+# [ ] ??? (TOS) Type of Service
+# [ ] ??? (RUL) Length of return UDP packet is correct
2009-04-15 15:46:37 +00:00
gera 8305242cdc More complete:
+# All Probes
+# [ ] SEQ
+# [ ] OPS
+# [ ] WIN
+# [x] T1
+# [x] T2
+# [x] T3
+# [x] T4
+# [x] T5
+# [x] T6
+# [x] T7
+# [ ] IE
+# [x] ECN
+# [ ] U1
+
+# All Tests
+
+# SEQ()
+# [ ] TCP ISN sequence predictability index (SP)
+# [ ] TCP ISN greatest common divisor (GCD)
+# [ ] TCP ISN counter rate (ISR)
+# [ ] IP ID sequence generation algorithm (TI)
+# [ ] IP ID sequence generation algorithm (CI)
+# [-] IP ID sequence generation algorithm (II)
+# [ ] Shared IP ID sequence Boolean (SS)
+# [ ] TCP timestamp option algorithm (TS)
+# OPS()
+# [+] TCP options (O, O1-O6)
+# WIN()
+# [+] TCP initial window size (W, W1-W6)
+# ECN, T1-T7
+# [+] TCP options (O, O1-O6)
+# [+] TCP initial window size (W, W1-W6)
+# [x] Responsiveness (R)
+# [x] IP don't fragment bit (DF)
+# [x] IP initial time-to-live (T)
+# [x] IP initial time-to-live guess (TG)
+# [x] Explicit congestion notification (CC)
+# [x] TCP miscellaneous quirks (Q)
+# [x] TCP sequence number (S)
+# [x] TCP acknowledgment number (A)
+# [x] TCP flags (F)
+# [ ] TCP RST data checksum (RD)
+# IE()
+# [ ] Responsiveness (R)
+# [ ] Don't fragment (ICMP) (DFI)
+# [ ] IP initial time-to-live (T)
+# [ ] IP initial time-to-live guess (TG)
+# [ ] ICMP response code (CD)
+# [ ] ??? (TOSI)
+# [ ] ??? (SI)
+# [ ] ??? (DLI)
+# U1()
+# [ ] Responsiveness (R)
+# [ ] IP don't fragment bit (DF)
+# [ ] IP initial time-to-live (T)
+# [ ] IP initial time-to-live guess (TG)
+# [ ] IP total length (IPL)
+# [ ] Unused port unreachable field nonzero (UN)
+# [ ] Returned probe IP total length value (RIPL)
+# [ ] Returned probe IP ID value (RID)
+# [ ] Integrity of returned probe IP checksum value (RIPCK)
+# [ ] Integrity of returned probe UDP checksum (RUCK)
+# [ ] Integrity of returned UDP data (RUD)
+# [ ] ??? (TOS)
+# [ ] ??? (RUL)
+
2009-04-15 15:43:52 +00:00