File tree Expand file tree Collapse file tree 8 files changed +67
-29
lines changed Expand file tree Collapse file tree 8 files changed +67
-29
lines changed Original file line number Diff line number Diff line change 1-
1+ # nmap: Evading Firewalls
22We are going to make assumptions which are very probable for many
33firewalls, but won't be accurate, because they can vary from
44firewall to firewall. We can list as anti-scanning technologies:
55
6- * Firewall
7- * NAT (Network Address Translation)
8- * IDS (Intrusion Detection System)
6+ - Firewall
7+ - NAT (Network Address Translation)
8+ - IDS (Intrusion Detection System)
99
1010We are going to discuss each and how they will affect the result.
1111
@@ -25,9 +25,9 @@ Decisions are primarily made based on the socket which is the
2525combination "SourceIP,SourcePort and DestIP,DestPort". There are
2626generally three types of firewall:
2727
28- * Stateless Packet Filter Firewall
29- * Stateful Packet Filter Firewall
30- * Application (aka Proxy) Firewall
28+ - Stateless Packet Filter Firewall
29+ - Stateful Packet Filter Firewall
30+ - Application (aka Proxy) Firewall
3131
3232We are not interested in the normal scans done with -sS or with
3333-sT because in these cases we simply receive a response (or the
Original file line number Diff line number Diff line change 1+ # nmap: Usage Examples
12
23Let's see now a real case example of NMAP usage, the first thing
34we do is:
@@ -16,9 +17,10 @@ network:
1617
1718``` sh
1819 nmap -sn -n 192.168.25.0/24
19- # in this case, we disabled port
20- # scanning with "-sn" and we disabled host name resolution with "
21- # -n", in this way we get quickly the list of live hosts on the
20+ # in this case, we:
21+ # disabled port scanning with "-sn";
22+ # we disabled host name resolution with "-n",
23+ # in this way we get quickly the list of live hosts on the
2224 # network, we didn't specify any specific option for host
2325 # enumeration, since we are doing this operation in a local
2426 # network, so no matter which options we would have used, it
Original file line number Diff line number Diff line change 1+ # nmap: host enumeration
12
23Nmap works at the OSI Network layer and Transport layer. We have
34to remember that each layer has its own:
Original file line number Diff line number Diff line change 1+ # nmap: ICMP
12
23ICMP is used to:
34
@@ -27,6 +28,29 @@ There are 3 types of request/response pairs:
2728The -PP and -PM requests can be used with some machines where ICMP ping requests
2829have been blocked only.
2930
31+ For example we could perform a ping sweep similar to what the UNIX or Windows
32+ ping tool does to discover hosts on a network by doing:
33+ ``` sh
34+ nmap -sn -n -PE 172.28.128.0/24
35+ # -sn turns off the port scanning
36+ # -n does not resolve the IP addresses into domain names
37+ # -PE uses ICMP type 8 messages to ping hosts on the subnet
38+ ```
39+
40+ Note that if we are on a local segment, we may also only see ARP packets,
41+ and this happens since nmap does as little as possible it can do to discover
42+ hosts. However we can see the ping probes whenever we try to perform this
43+ on a host outside our local network segment.
44+
45+ Whenever we want to force ping probes within our local network segment
46+ we can do:
47+ ``` sh
48+ sudo nmap -sO -p 1 -n -Pn < target>
49+ # in this case we:
50+ # `-Pn` disable the discovery phase (or "ping phase")
51+ # `-n` do not perform IP address resolution
52+ # `-sO -p 1` perform a raw IP scan where the -p1 indicates ICMP type 8 messages
53+ ```
3054
3155## One Flow Communication in ICMP
3256
Original file line number Diff line number Diff line change 1+ # nmap: NATed systems and Load Balancers
12
23Sometimes the IP address that we are scanning may be a firewall or a network
34device which is using NAT and behind this device there may be multiple systems.
@@ -10,11 +11,11 @@ with a NATed network.
1011
1112In this cases we can use TCP timestamps to infer what is the configuration:
1213
13- * if timestamps are significantly different(> 1s): It is very likely that timestamps
14+ - if timestamps are significantly different(` > 1s ` ): It is very likely that timestamps
1415 are coming from different systems
15- * if timestamps are euql ( <1s): It is likely that timestamps are coming from
16+ - if timestamps are equal ( ` <1s ` ): It is likely that timestamps are coming from
1617 the same system
17- * If only one port responds without set TCP timestamp options, it is
18+ - If only one port responds without set TCP timestamp options, it is
1819 safe to assume that two different systems are responding. If TSopts
1920 are not included in the answer or TSval = 0 on both ports, then no
2021 knowledge can be gained, because it could be the same system having
Original file line number Diff line number Diff line change @@ -46,7 +46,8 @@ Another basic example could be:
4646``` sh
4747 nmap -sn 192.168.1.0/24
4848 # in this case nmap just executes an enumeration of the
49- # hosts on the network address
49+ # hosts on the network address, it actually uses
50+ # different techniques to understand if a host is alive or not
5051```
5152Notice that Nmap has plenty of features, and can also integrate
5253script capabilities.
@@ -80,3 +81,16 @@ divided in this way:
8081* Script Scanning: execution of the user-mentioned scripts
8182* Ouput: printing of the output on stdout or in files
8283
84+
85+ In addition, we may say that as a guideline an nmap operation
86+ can be subdivided into two major phases:
87+ - host discovery (or "ping phase"), controlled with the -P option
88+ - port scan, controlled with the -s option
89+
90+ Also remember that the default behavior of nmap also depends on whether
91+ we are executing the command:
92+ - as root vs non-privileged user
93+ - on a local network segment vs to a remote host
94+
95+ That's why sometimes using the same flags could lead to a slightly
96+ different network traffic.
Original file line number Diff line number Diff line change 1+ # nmap Output
12
23Let's look at some way to obtain better output:
3-
4- * while in the interactive mode, if we are waiting for results we
4+ - while in the interactive mode, if we are waiting for results we
55 can press "Enter" and get some lines describing what nmap is
66 doing
7-
8- * if we append the --reason in any case nmap is doing a port scan,
7+ - if we append the --reason in any case nmap is doing a port scan,
98 we'll notice the reason why nmap determined that the examined
109 ports were closed or opened
11-
12- * if we are only interested in the open ports, and not even the
10+ - if we are only interested in the open ports, and not even the
1311 filtered ones, so we must append --open
14- * we can output the results in a file with: "-o", we can save
12+ - we can output the results in a file with: "-o", we can save
1513 results into different formats:
14+ - N, normal format
15+ - X, XML format
16+ - G, grepable format
17+ - A, all formats
1618
17- * N, normal format
18- * X, XML format
19- * G, grepable format
20- * A, all formats
21-
22- an example of these could be:
19+ An example of these could be:
2320``` sh
2421nmap -oN fileName.txt
2522```
2623
2724What I personally prefer in scanning activities is:
28-
2925``` sh
3026nmap -oA filename_prefix
3127```
Original file line number Diff line number Diff line change 1+ # nmap Port Scanning
12
23There are two technique to "Port Specification" in nmap:
34
451 . Explicitly using the "-p" flag
5-
662 . By reference using nmap-services
77
88## The "-p" flag
You can’t perform that action at this time.
0 commit comments