Pages

Saturday, December 26, 2015

Code Highlighting


I really hate javascript, and I hate being forced to allow it so I can view a webpage properly even more. So if you haven't noticed for the moment I am choosing to simply color any code commands until I find a workable solution. If you happen to know of one, please leave a comment!

Impacket SMB Connections Made Simple


So it kinda bugged me awhile ago when I was trying to learn impacket that there is not allot of documentation. The stuff that is out there is very select and rather old. Granted the best way to learn is to poke around and find the commands, but that proved very tiresome and not at all helpful. So I figured I would make a small post and explain some of the basics in the hopes that it might help someone else down the road.

There are many different ways to actually make a connection after trying a few I stumbled upon this and it seems the best... at least for me. It gives you access to all the upper level stuff as well as the low level stuff when and if you need it.

First we will import what we need:
from impacket.smbconnection import * 

For some help if you need it:
help(SMBConnection)

Now we will start our connection:
con = SMBConnection('127.0.0.1', '127.0.0.1', preferredDialect=SMB2_DIALECT_002)
Notice that we can choose which dialect to use, this will automatically perform the smb negotiation, and will default to the highest available... but you can also use these!
SMB_DIALECT, SMB2_DIALECT_002, SMB2_DIALECT_21, and SMB2_DIALECT_30

Now we can login:
con.login('Administrator', 'Password', 'DOMAIN')
con.login('Administrator', '', 'DOMAIN', nthash='yourNThashgoeshere')

Notice that we have to specify '' for the password if supplying a hash!

So now we are logged in and we can do just about anything we like, for example..
Lets list all the shares:
shares = con.listShares()
for n in shares:
   n.dump()


Lets write a file into the C:\Users folder... but remember your permissions WILL come into play.
f = open('/tmp/awesome.dll', 'rb') # open file read binary
con.putFile('C$', r'\\Users\\awesome.dll', f.read)
f.close()


Lets download the same file:
f = open('/tmp/new_awesome.dll', 'wb') # open file write binary
con.getFile('C$', r'\\Users\\awesome.dll', f.write)
f.close()


Now lets delete it:
con.deleteFile('C$', r'\\Users\\awesome.dll')

To access all the stuff in the SMB/SMB3 classes:
lower_level = con.getSMBServer()

That's gonna be all for now, I'll write up a more advanced post on the lower level stuff sometime soon.


Thursday, December 24, 2015

Hello World 2.0 

Its been a really long time since I have written anything worthwhile. So this is just a simple little test to make sure I still can and also to explain what this is for. Hopefully once a week ill be posting some cool things I have learned lately. This is going to be more for personal documentation but I also think there are at-least a few people that might find it useful. So if your reading this, check back every so often and see if you find some nifty stuff.

Sunday, December 20, 2015