diff --git a/README.md b/README.md index 6f194f4..ac7ff36 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ # Mikrotik netboot/initrd jailbreak -(C) Sergey Sergeev, 2019 +(C) Sergey Sergeev, 2019-2020 All that you do is at your own risk! The author has not liable for any of you actions and their consequences! This code is presented as is and is solely for educational purposes ONLY! -0) Use RouterOS 6.45.6 or 7.0b1! +0) Use RouterOS 6.44 or 6.45.6 or 7.0b1! 1) Upload(using FTP) content of ./for_ftp_upload/pub/* to /pub (or /flash or /flash/rw/disk/pub) folder on target RouterOS device 2) Netboot(via bootp and tftp) with kernel-new.elf @@ -27,7 +27,7 @@ For Developers: cd ./init ./compile.sh cd .. - Make the necessary changes to the ./cpio-fs-ARCH(compile add add busybox, etc...) + Make the necessary changes to the ./cpio-fs-ARCH(copy oldinit && order from ./bins/initramfs.cpio, compile add add busybox, etc...) In the end, when everything is ready, to get ./bins/kernel-new.elf, run: ./pack-kernel.sh Upload content of ./for_ftp_upload/pub/* to target RouterOS device via FTP(to /pub or /flash or ...) Put ./bins/kernel-new.elf to your tftp and Netboot from it diff --git a/cpio-fs-arm/init b/cpio-fs-arm/init index 15d567a..54837aa 100755 Binary files a/cpio-fs-arm/init and b/cpio-fs-arm/init differ diff --git a/cpio-fs-arm/oldinit b/cpio-fs-arm/oldinit index 7908653..d2087e9 100755 Binary files a/cpio-fs-arm/oldinit and b/cpio-fs-arm/oldinit differ diff --git a/cpio-fs-arm/order b/cpio-fs-arm/order index 37f0a62..fb01c1c 100755 Binary files a/cpio-fs-arm/order and b/cpio-fs-arm/order differ diff --git a/cpio-fs-arm/readme.txt b/cpio-fs-arm/readme.txt new file mode 100644 index 0000000..e9adba0 --- /dev/null +++ b/cpio-fs-arm/readme.txt @@ -0,0 +1 @@ +binary files from routeros arm 6.44! \ No newline at end of file diff --git a/for_ftp_upload/pub/OWL/bin/busybox b/for_ftp_upload/pub/OWL/bin/busybox index 0e98981..a5d7f1a 100755 Binary files a/for_ftp_upload/pub/OWL/bin/busybox and b/for_ftp_upload/pub/OWL/bin/busybox differ diff --git a/globals.sh b/globals.sh index a3fc602..333f364 100644 --- a/globals.sh +++ b/globals.sh @@ -3,8 +3,8 @@ #(C) Sergey Sergeev aka adron, 2019 # -#TARGET_ARCH="arm" -TARGET_ARCH="mips" +TARGET_ARCH="arm" +#TARGET_ARCH="mips" [ ${TARGET_ARCH} = "arm" ] && { OPENWRT_DIR=/home/prog/openwrt/lede-all/2019-openwrt-all/openwrt-ipq806x diff --git a/init/init.c b/init/init.c index 19f4ff8..e2c0844 100644 --- a/init/init.c +++ b/init/init.c @@ -21,26 +21,28 @@ void my_system(char *cmd, char *arg1, char *arg2, char *arg3){ waitpid(pid, NULL, 0); } -static char work_dir1[ ] = "/flash/rw/disk/pub"; -static char work_dir2[ ] = "/flash/rw/disk/flash/rw/disk/pub"; -static char *work_dir = work_dir1; +static char *work_dirs[ ] = { "/flash/rw/disk/pub", "/flash/rw/disk/flash/rw/disk/pub", NULL }; void daemonized_OWL(void){ int a = 0; + int ret = 0; static char bin_busybox[128]; static char owl_sh[128]; struct stat sb; + int work_dir_x = 0; + char *work_dir = NULL; while(1){ - /* if(a++ % 10 == 0){ - printf("OWL is here! %d\n", a); - }*/ - do{ //autodetect work_dir - if(work_dir == work_dir1) - work_dir = work_dir2; - else - work_dir = work_dir1; + do{//autodetect work_dir + work_dir = work_dirs[work_dir_x++]; + if(!work_dir){ + work_dir_x = 0; + continue; + } printf("%d: Trying work_dir: '%s'\n", a++, work_dir); - sleep(5); - }while(stat(work_dir, &sb) != 0); + memset(&sb, 0x0, sizeof(sb)); + sleep(5); //at first fast run it always return -1 + ret = stat(work_dir, &sb); + printf("stat() ret := %d\n", ret); + }while(ret != 0); printf("work_dir found at: '%s'\n", work_dir); snprintf(bin_busybox, sizeof(bin_busybox), "%s/OWL/bin/busybox", work_dir); snprintf(owl_sh, sizeof(owl_sh), "%s/OWL.sh", work_dir);