Wednesday, March 21, 2012

How to mount a drive as another user

This was a case of one of those issues where you constantly search for an answer to only have it staring you in the face the whole time *facedesk*

if you want to mount a drive as another user or have its group as something else, simply place uid=xxxx and/or gid=xxxx in the mount options.

for example:
     mount -t vfat /dev/sdb1 /mnt/kittens
will mount with root permissions (BOOOOOOO)
     mount -t vfat /dev/sdb1 /mnt/kittens -o uid=1000,gid=1000
will mount as the user that is uid=10000 with group permissions of gid=1000

now my hacked appletv will properly read that mounted drive for all my media crap. sweetities.

Persistent SSH Tunnel

I always have a box reverse ssh to one of my other boxes. This tunnel needs to stay up at all times and it need to come back after restarts. This is the solution:

Firstly I need to know exactly what command I will use for the reverse connection. This is mine:
  • ssh loldongs@loldongs.info -i /home/loldongs/.ssh/lin -N -T -R 4510:localhost:22
Great, now i need a "watcher" script that will constantly check if the connection is up; if so, do nothing; if not, start the damn thing.
#!/bin/bash
#make-run.sh
#make sure a process is always running.

export DISPLAY=:0 #needed if you are running a simple gui app.

process='ssh loldongs@loldongs.info -i /home/loldongs/.ssh/lin -N -T -R 4510:localhost:22'
makerun='ssh loldongs@loldongs.info -i /home/loldongs/.ssh/lin -N -T -R 4510:localhost:22'

if ps ax | grep -v grep | grep "$process" > /dev/null
        then
                exit
        else
        $makerun &
        fi
exit
I found this somewhere on the internet, i'm loving it. I mainly love it because all i have to do is call this script from cron every minute and i will ensure that the connection is never down for more than 60seconds.

Synchronizing torrent downloads

    I dual boot between win7 and ubuntu. The problem is when i log into one of those, typically i will sit in it for quite a long time. I'm also an impatient man so I dont want to only be able to download torrents while in only one or the other.
    I want to be able to download the same torrent whether im in linux, windows, or your mothers arse. I noticed that the majority of torrent clients will/can ask for 3 different folders.

  • A "completed" folder where the files will be moved upon full completed download
  • A "session" folder where the client stores files letting it know where the torrent is in the download
  • A "watch" folder that the client will constantly look at to integrate new torrents
I have many harddrives so I decided to allocate one of them to my torrent downloads where i can later organize into the different categories after download (read: bored).

This drive is mounted on my machine at /media/tdrive/
I created the following commands in that drive to hold all torrents and the such.

  1. mkdir /media/tdrive/torrents; cd !^
  2. mkdir torrents-watch
  3. mkdir torrents-completed
  4. mkdir torrents-session
Now that the folders are set up, you will have to configure your torrent clients to point to those directories. You can easily do so with .rtorrent.rc


# Default directory to save the downloaded torrents.
directory = /media/tdrive/torrents/torrents-completed


# Default session directory. Make sure you don't run multiple instance
# of rtorrent using the same session directory. Perhaps using a
# relative path?
session = /media/tdrive/torrents/torrents-session


# Watch a directory for new torrents, and stop those that have been
# deleted.
schedule = watch_directory,5,5,load_start=/media/tdrive/torrents/torrents-watch/*.torrent 




Now when I start rtorrent on linux, it will scan through the dirs and pick up the ones that still need to be downloaded. The same happens with utorrent in windows.

shablooie.

Dump Mac Ram Contents

My company installed AV and I saw it had a password with it. I wanted to know what that was so I decided to dump my RAM. Using this:

http://cybermarshal.com/index.php/cyber-marshal-utilities/mac-memory-reader

I was able to dump my contents to disk and open it in a hex editor to look for the portion that had the password. I found the password like i expected to, and i'm glad it isn't THAT awful a password like i feared.

Thursday, March 15, 2012

sudo: unable to resolve host loldongs

Apparently if you just change the hostname in /etc/hostname, sudo starts crying that it cant resolve the new hostname.

It looks like you can just add an entry in /etc/hosts for your new hostname to point to yourself (127.0.0.1) and then it gracefully shuts the fuck up.

woot.

SSH2_MSG_KEXINIT and ssh connections dropping

For some reason ssh was just choking when i was trying to connect to my BT5 install. ssh 192.168.1.107 -vv would result in the connection being reset. It turns out that the server didnt have the proper keys installed by default.

sshd-generate fixed the issue. everything worked afterwards

Bash trivia trick

If you want to feel smarter than someone else, try this little trick.

Challenge the other person to create a file on the filesystem by sending the shell only 3 characters.

Answer? super simple:

>a

1: >
2: a
3: 'new-line'

now if you do an 'ls' you can see the empty file 'a' was created in the current directory. This is a short way to create an empty file on the local system. Basically what is happening is you are redirecting nothing into a file, since that file didn't exist previously, it created it. Hence, creating an empty file.

Now you can reserve 'touch' for more fancy trickery (timestomping)

Friday, March 9, 2012

Disable FireWire completely on Mac

using inception, its super easy to dump a Mac's ram through the DMA feature of FireWire. This includes plaintext login passwords. I tried it, i saw my password, i wept.

Next step? obliterate firewire.

First step, move the firewire kext folder to you home directory for a backup:

sudo mv /System/Library/Extensions/IOFireWireFamily.kext ~

then make a placeholder directory for kicks and fun

sudo mkdir /System/Library/Extensions/IOFireWireFamily.kext/

then boot the mac using a system disk to set an openfirmware password.

once you set the password, the attack kind of stops working.

woot.