Tag Archives: Software

#TIL Some Unix Magics I Picked Up This Month

Posted on by 0 comment

So this month I picked up a couple of unix tricks which I wish I had have known years ago.

Tip #1.

Supervisor.
Supervisor is a service which will sustain a running process, you can tell it to auto start a command then make sure that process is always running. You can pick output files for STDOUT and STDERR then force a relaunch on any crash you might have.

Use Case: I was actually attempting to run deluged and deluge-web on a VPS I own, however often when adding a new torrent the server would crash, I’d need to ssh into the box and restart it. Now deluge restarts itself on every crash meaning I can upload and if it crashes it’ll come straight back up.

there is a good guide to setting up supervisor here Setting Up Supervisor.

Tip #2.

tmux.
tmux is a terminal multiplexer and it does exactly that. tmux will let you use all that empty space on the right of your terminal as a second terminal, it allows you to split your terminal into many many panes arrange those panes into default layouts or arrange them manually to suit your workflow. This of course has many use cases however the one that came to mind is when running an arp cache poison I usually have at least 3 tabs one for the router, one for the client, one for whatever it is you’re hoping to do with the traffic. With tmux you can run them all in the same terminal window without tabs and you can keep an eye on all your processes at once. It also looks awesome on larger screens. There is a number of cheat sheets available for tmux some of the ones I looked at:
https://gist.github.com/MohamedAlaa/2961058
https://gist.github.com/afair/3489752

But you can’t go past the man page:

http://www.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man1/tmux.1?query=tmux&sec=1

Building a Quick and Dirty Url Shortener

Posted on by 0 comment

At work last week we were discussing the security implications of url shortening services, such as tinyURL, biy.ly and goo.gl not only the fact that they can be used to hide malicious URLs for use in phishing attacks but the problem’s we’re having are:

  • Users in more restrictive access groups not being able to click links from these services
  • But worse, some users are using this service to shorten intranet links

Now that second point is an issue for me; if a shortening service were hacked our server names could be leaked to the world.

The two obvious solutions were ban all users from using such services or run our own internal service

My instinct told me that one shouldn’t be to hard to build.

So Here it is in less than 50 lines


from SimpleHTTPServer import SimpleHTTPRequestHandler
import StringIO,os,BaseHTTPServer,sqlite3
if "urls.db" in os.listdir("."):
    con = sqlite3.connect("urls.db")
    c=con.cursor()
else:
    con = sqlite3.connect("urls.db")
    c=con.cursor()
    c.execute("create table shorts (id integer primary key, url varchar unique)")
server = BaseHTTPServer.HTTPServer
server_address = ("", 8000)
class MyHandler(SimpleHTTPRequestHandler):
    def send_head(self):
        body,response = " ",200
        if self.path=="""/""":pass
        elif self.path.endswith("+"):
            c.execute('SELECT url FROM shorts WHERE id=(?)', (self.path[1:-1].decode("base64"),))
            s=c.fetchone()
            boady = s[0]        
        elif r"/add?" not in self.path:
                    response=301
            c.execute('SELECT url FROM shorts WHERE id=?', (self.path[1:].decode("base64"),))
            s=c.fetchone()    
            else:
                    x=self.path.split("?",1)[-1].replace(r"http://","")
            try:
                c.execute("insert into shorts(url) values (?)", (x,))
                con.commit()
            except sqlite3.IntegrityError:pass
            c.execute('SELECT id FROM shorts WHERE url=(?)', (x,))
            s=c.fetchone()
            body = "ok. " + str(s[0]).encode("base64")
        self.send_response(response)  
        self.send_header("Content-type", "text/html; charset=utf-8")  
        self.send_header("Content-Length", str(len(body)))  
        if response==301:
            self.send_header("Location","http://"+s[0])          
        self.end_headers()
                return StringIO.StringIO(body)
httpd = server(server_address, MyHandler)
print "Starting server..."
try:
    httpd.serve_forever()
except KeyboardInterrupt:
    httpd.socket.close()
Category: Python, Software | Tags: , ,

Unlocked Windows Tools

Posted on by 0 comment

I was reading about the iKAT tools; I came across their set of binaries that don’t obey GP. These are awesome and if you couple them with the base64 file encoding proxy I wrote a while ago. With this you should be able to get full cmd access on just about any environment where you have internet access. the tools included in the iKAT package are:
cmd.exe
command.com
control.exe
cscript.exe
explorer.exe
ipconfig.exe
osk.exe
rasphone.exe
regedit.exe
runonce.exe
sc.exe
taskman.exe
taskmgr.exe
wscript.exe
And the complete zip is mirrored here.

Windows 8 First Impressions

Posted on by 0 comment

My first impressions of windows 8 were somewhat exactly what I expected the install was great. I deleted my partitions and hit go. Went to sleep. Low and behold it was not waiting for me at some pesky config screen asking about my timezone. It was done I had to do a few house keeping configs like create accounts and put in the wifi settings but none of the hassle that xp and 7 installs had. Now I was installing this on an older machine a hp-210 netbook to be exact. It has a tiny dual core 1Ghz Intel atom and only a couple of gigs of RAM. Which is well within the system requirements for a 32bit OS. Wanting to try out this metro hooha I clicked on a metro app and was greeted by a message stating that my resolution was to low in face it was only about 178 pixels to low. I figured they all couldn’t be broken for something like a screen resolution but they were, all except the new faithful looking desktop app. So clicking the desktop app I have a task bar without the start button. I need a start button. It did however show me in a handy tooltip if I corner my mouse I get a settings dock. Finding me screen resolution settings I tried to up it so I could use the metro apps. But my screen only supports up to 600 pixels so just like every operating system I ever use it requires some hacking before it works like they say it does. I found the regKey “Display1_DownScalingSupported” after a bit of googling it’s a Boolean either 1 or 0 and setting it to 1 allows you to set your resolution beyond that of your screen with some funky downscaling majik but IMO it looks like crap on my 1024×600 screen but the metro apps now work. And after all this I still don’t like this new crazy interface.

Category: Phones, Software | Tags: ,

Compressing GUIDs

Posted on by 0 comment

GUIDs are the Globally unique Identifiers used by windows to install and identify software; they are used in the registry to ensure that keys used that piece of software are unique, a normal guid will look like this {XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX} but this guid is only one of the ways software will identify it’s self in the registry. You can also have a compressed GUID which you can get from a normal GUID by following this process

The first group of eight hexadecimal digits are placed in reverse order:

ABCDEFGH becomes HGFEDCBA

The same is done with the second group of four hexadecimal digits:

IJKL becomes LKJI

The same is done with the third group of four hexadecimal digits:

MNOP becomes PONM

In the fourth group of four hexadecimal digits, every two digits switch places:

1234 becomes 2143

In the last group of 12 hexadecimal digits, again every two digits switch places:

Lastly remove all {} ans -’s

python function to do this for you

compress_guid=(lambda guid:"".join(map(lambda x: x[::-1],guid[0:3])+map(lambda x:''.join([x[i:(i+2):][::-1]for i in range(0,len(x),2)]),guid[4:])))

compressed GUIDs occur in various places in the registry common ones being
HKEY_LOCAL_MACHINESOFTWAREClassesInstallerProducts
and somewhere under
HKEY_CLASSES_ROOT