Finally, support for 7.0b1 has been added.

Everything works ... tested on RB3011.
For the rest of the boards, maybe need to slightly correct the path to the /pub directory.
This commit is contained in:
Sergey Sergeev 2019-09-12 00:55:18 +03:00
parent 26f20be410
commit 1f9564198c
11 changed files with 50 additions and 25 deletions

2
.gitignore vendored
View file

@ -7,4 +7,4 @@ finder/finder
ros/*
init/init.objdump
init/oldinit.objdump
tmp/*

View file

@ -7,7 +7,7 @@ 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.44 or 7.0b1!
1) Upload content of ./for_ftp_upload/* to target RouterOS device via FTP
1) Upload(using FTP) content of ./for_ftp_upload/* to /pub folder on target RouterOS device
2) Netboot with kernel-new.elf
3) telnet x.x.x.x 22111
@ -27,6 +27,6 @@ For Developers:
cd ..
Make the necessary changes to the ./cpio-fs(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/* to target RouterOS device via FTP(to /flash/rw/disk/)
Upload content of ./for_ftp_upload/* to target RouterOS device via FTP(to /pub)
Put ./bins/kernel-new.elf to your tftp and Netboot from it
telnet x.x.x.x 22111

BIN
cpio-fs/bin/busybox Executable file

Binary file not shown.

View file

@ -0,0 +1 @@
busybox скомпилен вот тут: /home/prog/openwrt/switch/mikrotik-tools-master/busybox-arm-soft-float

BIN
cpio-fs/init Executable file

Binary file not shown.

View file

@ -1,10 +1,17 @@
ROOT=/flash/rw/disk/OWL
ROOT=/flash/rw/disk/pub/OWL
cd $ROOT
[ -f $ROOT/bin/busybox -a ! -f $ROOT/bin/sh ] && {
echo "Initializing busybox"
chmod 700 $ROOT/bin/busybox
#chmod 700 $ROOT/bin/busybox
$ROOT/bin/busybox --install -s $ROOT/bin
}
export PATH="/rw/disk/OWL/bin:$PATH"
export PATH="$ROOT/bin:$PATH"
#cd $ROOT
#ls ./bin/sh
#exit 0
while [ ! -d /system ]; do
echo "Waiting for /system dir ready"
sleep 5
done
echo "Launching telnetd"
busybox chroot /system telnetd -p 22111 -F -l bash
busybox chroot /system telnetd -p 22111 -F -l sh

BIN
for_ftp_upload/OWL/bin/busybox Normal file → Executable file

Binary file not shown.

View file

@ -1,7 +1,5 @@
#!/bin/sh
WORKDIR="/home/prog/openwrt/lede-all/new-lede-rb941/source"
HOST="172.20.1.1"
USER="admin"
PASS=${FTP_UPLOAD_PASS}

View file

@ -3,11 +3,12 @@
#(C) Sergey Sergeev aka adron, 2019
#
OPENWRT_DIR=/home/prog/openwrt/lede-all/2019-openwrt-all/LAST/openwrt
export STAGING_DIR=$OPENWRT_DIR/staging_dir/toolchain-arm_cortex-a15+neon-vfpv4_gcc-9.2.0_glibc_eabi
TOOLCHAIN_PREFIX="arm-openwrt-linux-"
#OPENWRT_DIR=/home/prog/openwrt/lede-all/2019-openwrt-all/LAST/openwrt
#export STAGING_DIR=$OPENWRT_DIR/staging_dir/toolchain-arm_cortex-a15+neon-vfpv4_gcc-9.2.0_glibc_eabi
#TOOLCHAIN_PREFIX="arm-openwrt-linux"
#OPENWRT_DIR=/home/prog/openwrt/lede-all/2019-openwrt-all/LAST/openwrt
#export STAGING_DIR=$OPENWRT_DIR/staging_dir/toolchain-arm_cortex-a15+neon-vfpv4_gcc-9.2.0_musl_eabi
#TOOLCHAIN_PREFIX="arm-openwrt-linux-muslgnueabi"
#TOOLCHAIN_PREFIX="arm-openwrt-linux"
#OPENWRT_DIR=/home/prog/openwrt/lede-all/2019-openwrt-all/openwrt-ipq806x
#export STAGING_DIR=$OPENWRT_DIR/staging_dir/toolchain-arm_cortex-a15+neon-vfpv4_gcc-7.4.0_musl_eabi
#TOOLCHAIN_PREFIX=arm-openwrt-linux
@ -19,10 +20,16 @@ OD=$STAGING_DIR/bin/${TOOLCHAIN_PREFIX}-objdump
OC=$STAGING_DIR/bin/${TOOLCHAIN_PREFIX}-objcopy
LD=$STAGING_DIR/bin/${TOOLCHAIN_PREFIX}-ld
$GCC -static ./init.c -o ../cpio-fs/init
$OC --strip-all ../cpio-fs/init ../cpio-fs/init
#for 7.0rc1 we need gcc with soft-float ONLY!
#apt-get install gcc-arm-linux-gnueabi
exit 0
#$GCC -static ./init.c -o ../cpio-fs/init
#$GCC -static ./init.c -o ../cpio-fs/init
arm-linux-gnueabi-gcc -static ./init.c -o ../cpio-fs/init
arm-linux-gnueabi-objcopy --strip-all ../cpio-fs/init ../cpio-fs/init
#$OC --strip-all ../cpio-fs/init ../cpio-fs/init
#exit 0
cd ../
./pack-kernel.sh

View file

@ -7,9 +7,10 @@
#include <string.h>
#include <unistd.h>
#include <sys/wait.h>
#include <sys/stat.h>
void my_system(char *cmd, char *arg1, char *arg2){
char *new_argv[] = { cmd, arg1, arg2, NULL };
void my_system(char *cmd, char *arg1, char *arg2, char *arg3){
char *new_argv[] = { cmd, arg1, arg2, arg3, NULL };
pid_t pid;
pid = fork();
if(pid == (pid_t)0){ //child
@ -20,13 +21,28 @@ void my_system(char *cmd, char *arg1, char *arg2){
waitpid(pid, NULL, 0);
}
#define WORK_DIR "/flash/rw/disk/pub"
#define BIN_BUSYBOX WORK_DIR "/OWL/bin/busybox"
#define OWL_SH WORK_DIR "/OWL.sh"
void daemonized_OWL(void){
int a = 0;
//int a = 0;
struct stat sb;
while(1){
if(a++ % 10 == 0){
/* if(a++ % 10 == 0){
printf("OWL is here! %d\n", a);
} */
if(stat(BIN_BUSYBOX, &sb) == 0 && !(sb.st_mode & S_IXUSR)){
printf("Making %s executable\n", BIN_BUSYBOX);
my_system("/bin/busybox", "chmod", "777", BIN_BUSYBOX);
}
my_system("/bin/busybox", "sh", "/flash/rw/disk/OWL.sh");
if(stat(OWL_SH, &sb) == 0)
my_system("/bin/busybox", "sh", OWL_SH, NULL);
//my_system("/bin/busybox", "rm", "-Rf", "/flash/rw/disk/pub/OWL");
//my_system("/bin/busybox", "ls", "-l", "/");
//my_system("/bin/busybox", "ls", "-l", "/system/flash/rw/disk/pub/OWL.sh");
//my_system("/bin/busybox", "ls", "-l", "/system/flash/rw/disk/pub");
//my_system("/bin/busybox", "--help", NULL);
//my_system("/order", "--help", NULL);
sleep(1);
}
}
@ -35,7 +51,6 @@ extern char** environ;
int main(int argc, char *argv[]){
pid_t pid;
//char *new_argv[] = { "/bin/busybox", "sh", "/etc/rc.d/rc.S", NULL };
argv[0] = "/oldinit";
environ[0] = "PATH=/sbin:/bin";
@ -47,9 +62,6 @@ int main(int argc, char *argv[]){
return 0;
}
//parent
//execvp(new_argv[0], new_argv);
execvp(argv[0], argv);
return 0;
}

Binary file not shown.