4 ms·
> Since I wasn’t root and couldn’t install any tools (guess I could have copied a netstat binary across) If you have the ability to write anywhere to disk (e.g
by deathanatos 9y ago
> Since I wasn’t root and couldn’t install any tools (guess I could have copied a netstat binary across)
If you have the ability to write anywhere to disk (e.g., even /tmp, /run), dropping a copy of Busybox (a statically linked, minimal clone of many of the base tools like ifconfig, netstat) has helped me more than once.
(I didn't have a working scp on a machine, and it was the ssh "gateway" to another machine that I needed access to. To jump to the next machine, I needed to run either ssh or nc, both of which were defunct (the HDD was dying). Copied busybox over for nc, and it worked like a charm. I had to write a small python script to transform the binary into a printf command to write it out to disk, as essentially nothing but bash builtins worked due to the condition of the disk. Had a minor panic attack when I realized I needed to chmod +x it, but chmod still worked. In hindsight, I think I could have set the umask prior to the printf to avoid that step.)
- digi_owl 9y agoSounds similar to an old UNIX rescue story...
- laumars 9y agoI know you've already solved this problem, but a few tips I've learned along the way in case you - or anyone else - runs into this problem again: If only Bash worked then you can use Bash's builtin TCP/IP stack[1][2] to transfer data (inc files)[1][2] [1] http://www.linuxjournal.com/content/tech-tip-tcpip-access-using-bash http://www.linuxjournal.com/content/tech-tip-tcpip-access-us... [2] http://www.linuxjournal.com/content/more-using-bashs-built-devtcp-file-tcpip http://www.linuxjournal.com/content/more-using-bashs-built-d... This is how I got around a similar problem as yourself regarding needing to get a file on a system which was severely locked down. Also you can get around the `chmod +x` problem by calling ld directly[3] [3] https://superuser.com/a/341471 https://superuser.com/a/341471
- zeroDivisible 9y agoI did not thought about passing a binary to `ld` directly, that's quite cool actually.
- rdtsc 9y agoI like Bash's TCP thing. First time I saw it thought a coworker was pulling my leg. Since then I've used it in a few places like talking to a metrics daemon on localhost, or just debugging various issues. The most fun thing is to show it to others as almost everyone is surprised about it.
- feelin_googley 9y ago"I had to write a small python script to transform the binary into a printf command to write it out to disk, as essentially nothing but bash builtins worked due to the condition of the disk." Why not create a tmpfs directory over some existing directory? Why try to write to disk when the disk is known to be malfunctioning? Then send the static binaries needed to the tmpfs directory, e.g., using netcat. Perhaps I have misunderstood the problem. Many years ago, I once tried a pre-packaged, well-regarded, "system rescue live CD". When I tried to use it on a computer with a malfunctioning disk, the rescue CD would fail to boot. Apparently it tried to access the computers HDD during boot. I switched to using another less-hyped OS to boot from USB stick into RAM and encountered no problems rescuing the malfunctiong HDD. Oh well. Why try to use use the disk if it is not working?