text
stringlengths
0
1.99k
return
elif msg[0] == ord('r'):
# Read Bytes
addr = int(msg[1:].strip(b'\n'), 16)
out = read_from_phy_memory(ser, addr)
conn.send(bytes(hex(out), "UTF-8"))
elif msg[0] == ord('w'):
# Write Bytes
address = msg[1:].split(b" ")[0]
value = msg[1:].split(b" ")[1].strip(b'\n')
write_to_phy_memory(ser, int(address, 16), int(value, 16))
conn.send(b'1')
msg = conn.recv(1024)
def splash():
print('[~ * ~ [WR940N MMIO MITM] ~ * ~]')
print('[>>>>>>>>>>> by: b1ack0wl <<<<<<<<<<<]')
def main():
ser = serial.Serial(
port='/dev/ttyUSB1', # Note: Change this for your USB serial device
baudrate=115200
)
already_open = test_uboot_cmd_line(ser, "0wl")
ser.isOpen()
if (already_open != True):
print(f'[*] Attempting to get the WR940N into the Das U-Boot shell...')
if (spam_tpl_for_uboot(ser, 5000) == False):
ser.close()
return
else:
print(f"[*] Router is already in the Das U-boot shell :D")
ser.write(b'\n\n')
listen_and_respond(ser, 1337)
if __name__ == '__main__':
splash()
main()
print('[*] - Done')
```
This is the Qemu board code.
* It needs to be put in the `qemu/hw/mips` folder.
* NOTE: Only GPIO, SPI, and DDR are mapped, it is up to the reader to
complete the rest
```
/*
* System emulation for the WR940N V6 board, but stripped for Phrack
* by b1ack0wl <3
*/
#include "qemu/osdep.h"
#include "qapi/error.h"
#include "qemu/datadir.h"
#include "exec/address-spaces.h"
#include "hw/clock.h"
#include "hw/mips/mips.h"
#include "net/net.h"
#include "sysemu/sysemu.h"
#include "hw/boards.h"
#include "hw/loader.h"
#include "elf.h"
#include "hw/sysbus.h"
#include "hw/qdev-properties.h"
#include "qemu/error-report.h"
#include "sysemu/qtest.h"
#include "sysemu/reset.h"
#include "sysemu/runstate.h"
#include "cpu.h"
#include "hw/mips/wr940n.h"
int client_fd = 0; // global lol
#define BIOS_FILENAME "u-boot.bin"
static struct _loaderparams {
int ram_size;
const char *kernel_filename;
const char *kernel_cmdline;
const char *initrd_filename;
} loaderparams;
typedef struct ResetData {
MIPSCPU *cpu;
uint64_t vector;
} ResetData;
static uint64_t load_kernel(void)
{
uint64_t entry, kernel_high, initrd_size;
long kernel_size;
ram_addr_t initrd_offset;
kernel_size = load_elf(loaderparams.kernel_filename, NULL,
cpu_mips_kseg0_to_phys, NULL,
&entry, NULL,
&kernel_high, NULL, TARGET_BIG_ENDIAN,
EM_MIPS, 1, 0);
if (kernel_size < 0) {
error_report("could not load kernel '%s': %s",