Discuss Scratch

herohamp
Scratcher
1000+ posts

Run binary from inside bash file/Downloading and executing binary

Is it possible for me to package a binary inside of a bash file and then execute it? I know this seems like an odd request but is it possible. I know this seems like an odd request but I am working with a Write Protected disk so I can't save any files to. Currently, to run bash files I have to do something like
curl -s http://192.168.1.235/test.txt | bash

Or does anyone know a way to download an execute a binary as this is all the pre installed binarys I have to work with

cksum      head       less       md5sum     nslookup   sha1sum    sha256sum  sha512sum  sum        tail
ld-2.17.so libcurl.so.4 libnss_compat-2.17.so libnss_dns.so.2 libnss_nis-2.17.so libresolv.so.2 libz.so.1.2.8
ld-linux-armhf.so.3 libcurl.so.4.2.0 libnss_compat.so.2 libnss_files-2.17.so libnss_nis.so.2 libssh2.so.1
libc-2.17.so libdl-2.17.so libnss_db-2.17.so libnss_files.so.2 libnss_nisplus-2.17.so libssh2.so.1.0.1
libc.so.6 libdl.so.2 libnss_db.so.2 libnss_hesiod-2.17.so libnss_nisplus.so.2 libssl.so.1.0.0
libcrypto.so.1.0.0 libgcc_s.so.1 libnss_dns-2.17.so libnss_hesiod.so.2 libresolv-2.17.so libz.so.1
ash bash busybox catv curl date egrep fgrep grep gunzip gzip ls pwd sh tar zcat
Wettining
Scratcher
500+ posts

Run binary from inside bash file/Downloading and executing binary

 wget -O -[download-link].sh | bash 
maybe, I don't fully understand what your saying

Last edited by Wettining (July 21, 2017 04:16:58)

herohamp
Scratcher
1000+ posts

Run binary from inside bash file/Downloading and executing binary

Wettining wrote:

 wget -O -[download-link].sh | bash 
maybe, I don't fully understand what your saying
Thats like 50% as I want to be able to include a binary like say “date” with the bash file and execute it
MegaApuTurkUltra
Scratcher
1000+ posts

Run binary from inside bash file/Downloading and executing binary

busybox mount -t whatever \\\\my-awesome-nas\\someplace /mnt/my-awesome-writable-filesystem

Or if you have root remount whatever you're on as rw

Last edited by MegaApuTurkUltra (July 21, 2017 14:35:59)


$(".box-head")[0].textContent = "committing AT crimes since $whenever"
bobbybee
Scratcher
1000+ posts

Run binary from inside bash file/Downloading and executing binary

curl https://totally.legit/binary > binary
chmod +x binary
./binary
rm binary

Although I guarentee if you do that without a good reason, your security-aware userbase won't touch that script with a 10 foot pole.

“Ooo, can I call you Señorita Bee?” ~Chibi-Matoran
CatIsFluffy
Scratcher
100+ posts

Run binary from inside bash file/Downloading and executing binary

bobbybee wrote:

>
Please read this part of the OP:

herohamp wrote:

I know this seems like an odd request but I am working with a Write Protected disk so I can't save any files to.
nanalan
Scratcher
100+ posts

Run binary from inside bash file/Downloading and executing binary

$ /lib/ld-linux.so.2 <(curl thing)

some
BODY
once told me
DatOneLefty
Scratcher
1000+ posts

Run binary from inside bash file/Downloading and executing binary

sudo mkdir -p /media/tRAM
sudo mount -t tmpfs -o size=64M tmpfs /media/tRAM
cd /media/tRAM
wget https://totally.not/shady.binary
chmod +x shady.binary
./shady.binary
cd ~
sudo umount /media/tRAM

completely untested and my not work


Scratch data available at ScratchDB (Status)

Posts: bf97b44a7fbd33db070f6ade2b7dc549 (btw i use arch)
MegaApuTurkUltra
Scratcher
1000+ posts

Run binary from inside bash file/Downloading and executing binary

^ I think you meant busybox mount, busybox wget, busybox chmod, busybox umount.
Also mkdir would fail

Edit: nanalan's answer will not work either

Last edited by MegaApuTurkUltra (July 21, 2017 16:07:38)


$(".box-head")[0].textContent = "committing AT crimes since $whenever"
Wettining
Scratcher
500+ posts

Run binary from inside bash file/Downloading and executing binary

herohamp wrote:

Wettining wrote:

 wget -O -[download-link].sh | bash 
maybe, I don't fully understand what your saying
Thats like 50% as I want to be able to include a binary like say “date” with the bash file and execute it
 wget -O -[download-link].sh | bash | echo date 

Last edited by Wettining (July 21, 2017 17:57:59)

gtoal
Scratcher
1000+ posts

Run binary from inside bash file/Downloading and executing binary

herohamp wrote:

Is it possible for me to package a binary inside of a bash file and then execute it? I know this seems like an odd request but is it possible. I know this seems like an odd request but I am working with a Write Protected disk so I can't save any files to. Currently, to run bash files I have to do something like
curl -s http://192.168.1.235/test.txt | bash

Or does anyone know a way to download an execute a binary as this is all the pre installed binarys I have to work with


Is there a writable area, eg /tmp? You can embed a binary in your shell file (eg uuencoded) and save it out to /tmp to be executed.

Last edited by gtoal (July 21, 2017 22:52:51)

Jonathan50
Scratcher
1000+ posts

Run binary from inside bash file/Downloading and executing binary

Are you sure it's a binary? Binaries don't have txt extension. Maybe you need to xxd -r?

Edit: Whoops, nevermind

Last edited by Jonathan50 (July 21, 2017 23:21:01)


Not yet a Knight of the Mu Calculus.
Jonathan50
Scratcher
1000+ posts

Run binary from inside bash file/Downloading and executing binary

MegaApuTurkUltra wrote:

busybox mount -t whatever \\\\my-awesome-nas\\someplace /mnt/my-awesome-writable-filesystem

Or if you have root remount whatever you're on as rw
The node you mount the filesystem on has to exist, so that won't work unless you already have a directory at /mnt/my-awesome-writable-filesystem.

Not yet a Knight of the Mu Calculus.
herohamp
Scratcher
1000+ posts

Run binary from inside bash file/Downloading and executing binary

MegaApuTurkUltra wrote:

busybox mount -t whatever \\\\my-awesome-nas\\someplace /mnt/my-awesome-writable-filesystem

Or if you have root remount whatever you're on as rw
/ $ busybox mount -t whatever \\ubuntu\herohamp /mnt/my-awesome-writable-filesystem
mount: applet not found

Jonathan50
Scratcher
1000+ posts

Run binary from inside bash file/Downloading and executing binary

You've got a busybox binary built without mount. Do you have /tmp? What are you trying to do?

Last edited by Jonathan50 (July 22, 2017 00:46:12)


Not yet a Knight of the Mu Calculus.
herohamp
Scratcher
1000+ posts

Run binary from inside bash file/Downloading and executing binary

Jonathan50 wrote:

You've got a busybox binary built without mount. Do you have /tmp? What are you trying to do?
I have /tmp but can't write to it. I'm trying to put binaries on a USB drives to run on my router.
Jonathan50
Scratcher
1000+ posts

Run binary from inside bash file/Downloading and executing binary

Why can't you put the binaries on the USB drive?

Not yet a Knight of the Mu Calculus.
herohamp
Scratcher
1000+ posts

Run binary from inside bash file/Downloading and executing binary

Jonathan50 wrote:

Why can't you put the binaries on the USB drive?
I can but I can't mount the drive, so I need to send it binaries to mount the USB drive. Right?
Jonathan50
Scratcher
1000+ posts

Run binary from inside bash file/Downloading and executing binary

herohamp wrote:

I can but I can't mount the drive, so I need to send it binaries to mount the USB drive. Right?
Oh, sorry! xD You can't pass parameters to the kernel can't you? Is it on a ROM or a R/W storage device that's just mounted as read-only?

Last edited by Jonathan50 (July 22, 2017 00:57:07)


Not yet a Knight of the Mu Calculus.
herohamp
Scratcher
1000+ posts

Run binary from inside bash file/Downloading and executing binary

Jonathan50 wrote:

herohamp wrote:

I can but I can't mount the drive, so I need to send it binaries to mount the USB drive. Right?
Oh, sorry! xD You can't pass parameters to the kernel can't you? Is it on a ROM or a R/W storage device that's just mounted as read-only?
I can verify its R/W mounted as read-only because the router edits files. Infact I was able to add Hello to the bottom of a config file by adding \nHello. via the api

https://images.discordapp.net/attachments/335101418560028673/337927376514056193/unknown.png

Last edited by herohamp (July 22, 2017 01:00:23)

Powered by DjangoBB