Archive for the “hacking” Category
Posted by Buzz in hacking, Mac
So you wanted to get your aircrak suite on under OSX, getting airodump etc to work I can tell you will be a nightmare (infact just dont use a VM with a USB wifi for that, however there is an alternative …), after a lot of searching there is a native tool under OSX that will let you cap packets, list networks etc.
Credit goes to d3in0s for his awesome forum post.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
| /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport
Usage: airport <interface> <verb> <options>
<interface>
If an interface is not specified, airport will use the first AirPort interface on the system.
<verb is one of the following:
prefs If specified with no key value pairs, displays a subset of AirPort preferences for
the specified interface.
Preferences may be configured using key=value syntax. Keys and possible values are specified below.
Boolean settings may be configured using 'YES' and 'NO'.
DisconnectOnLogout (Boolean)
JoinMode (String)
Automatic
Preferred
Ranked
Recent
Strongest
JoinModeFallback (String)
Prompt
JoinOpen
KeepLooking
DoNothing
RememberRecentNetworks (Boolean)
RequireAdmin (Boolean)
RequireAdminIBSS (Boolean)
RequireAdminNetworkChange (Boolean)
RequireAdminPowerToggle (Boolean)
WoWEnabled (Boolean)
logger Monitor the driver's logging facility.
sniff If a channel number is specified, airportd will attempt to configure the interface
to use that channel before it begins sniffing 802.11 frames. Captures files are saved to /tmp.
Requires super user privileges.
debug Enable debug logging. A debug log setting may be enabled by prefixing it with a '+', and disabled
by prefixing it with a '-'.
AirPort Userland Debug Flags
DriverDiscovery
DriverEvent
Info
SystemConfiguration
UserEvent
PreferredNetworks
AutoJoin
IPC
Scan
802.1x
Assoc
Keychain
RSNAuth
WoW
AllUserland - Enable/Disable all userland debug flags
AirPort Driver Common Flags
DriverInfo
DriverError
DriverWPA
DriverScan
AllDriver - Enable/Disable all driver debug flags
AirPort Driver Vendor Flags
VendorAssoc
VendorConnection
AllVendor - Enable/Disable all vendor debug flags
AirPort Global Flags
LogFile - Save all AirPort logs to /var/log/airport.log
<options> is one of the following:
No options currently defined.
Examples:
Configuring preferences (requires admin privileges)
sudo airport en1 prefs JoinMode=Preferred RememberRecentNetworks=NO RequireAdmin=YES
Sniffing on channel 1:
airport en1 sniff 1
LEGACY COMMANDS:
Supported arguments:
-c[<arg>] --channel=[<arg>] Set arbitrary channel on the card
-z --disassociate Disassociate from any network
-I --getinfo Print current wireless status, e.g. signal info, BSSID, port type etc.
-s[<arg>] --scan=[<arg>] Perform a wireless broadcast scan.
Will perform a directed scan if the optional <arg> is provided
-x --xml Print info as XML
-P --psk Create PSK from specified pass phrase and SSID.
The following additional arguments must be specified with this command:
--password=<arg> Specify a WPA password
--ssid=<arg> Specify SSID when creating a PSK
-h --help Show this help
Credit goes to <a href="http://forum.aircrack-ng.org/index.php?PHPSESSID=osr5e11icl40hib1f57qkh0u35&topic=293.msg34031#msg34031">d3in0s post</a> showing true forum awesomeness.
<code>
/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I
agrCtlRSSI: -40
agrExtRSSI: 0
agrCtlNoise: -92
agrExtNoise: 0
state: running
op mode: station
lastTxRate: 54
maxRate: 54
lastAssocStatus: 0
802.11 auth: open
link auth: wpa2-psk
BSSID: <removed>
SSID: <removed>
MCS: -1
channel: 6
/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -s
SSID BSSID RSSI CHANNEL HT CC SECURITY (auth/unicast/group)
<removed> <removed> -41 6 N -- WPA(PSK/AES,TKIP/TKIP) WPA2(PSK/AES,TKIP/TKIP) |
Doing a frame cap.
1 2
| /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport en1 sniff 6
Capturing 802.11 frames on en1. |
You will see your airport icon changes to now hit ctrl+c to stop the cap
1
| ^CSession saved to /tmp/airportSniff813ZrA.cap. |
Tags: airport, osx, pcap, pentesting, wifi
No Comments »
Posted by Buzz in hacking, php
In theroy this: http://www.exploit-db.com/exploits/17423/ could be used to facilitate phishing,
To patch this update to 1.9.28, and apply this patch: https://raw.github.com/Oneiroi/PenTesting/master/patches/wptouch-edb17423.patch
UPDATE 07072011 .9.30 does not suffer from this exploit.
No Comments »
Posted by Buzz in hacking, php
In theory this: http://www.exploit-db.com/exploits/17423/ could be used to facilitate phishing,
To patch this update to 1.9.28, and apply this patch: https://raw.github.com/Oneiroi/PenTesting/master/patches/wptouch-edb17423.patch
1 2 3
| cd /path/to/blog/wp-content/plugins/wptouch/
wget https://raw.github.com/Oneiroi/PenTesting/master/patches/wptouch-edb17423.patch
patch < wptouch-edb17423.patch |
update This: http://wordpress.org/news/2011/06/passwords-reset/ causes a 1.9.29 version to be rolled out.
1.9.29 is still vulnerable to this, the patch instructions above still work for 1.9.29
Tags: 17423, edb, patch, phishing, wptouch
No Comments »
Go ahead and run
1
| curl -I http://www.saiweb.co.uk |
You will get
1 2 3 4 5 6 7 8
| HTTP/1.1 200 OK
Date: Mon, 25 Apr 2011 19:33:29 GMT
Server: Apache
Vary: Accept-Encoding,Cookie
Cache-Control: max-age=3, must-revalidate
WP-Super-Cache: Served supercache file from PHP
Connection: close
Content-Type: text/html; charset=UTF-8 |
As an attacker looking to hit a web app, one of the first things you’re going to want to look into is what version of web server is running, in this case you can see this blog in fact runs apache … but there is not much else to go on here is there.
That’s intentional, and by manual configuration changes I have put in place, this is not the case of a default LAMP install, take for instance, this snippet from another website,
1 2
| Server: Apache/2.2.16 (Debian)
X-Powered-By: PHP/5.2.14 |
This already has given me a wealth of information to go on and begin prepping an attack, I now know the site is running php version 5.2.14 Apache version 2.2.16 and that the underlying OS is Debian.
See the dilemma? your default roll outs are just declaring their running versions to anyone willing to listen, so lets make it a little more stealthy.
First and foremost if you are using php, edit your php.ini and set the following:
Now head into your httpd.conf and set the following
and
With these 3 simple steps all the headers will now return is Server: Apache this is the first step to shielding your app, I’ll be covering further steps as time allows.
Tags: Apache, hacking, Linux, security
2 Comments »
Posted by Buzz in hacking
With work returning to “normal” levels I began digging through my backlog of seclist updates, errata updates and security related podcasts,
One particular attack method has me concerned as a typical Paranoid Systems Admin, namely the one covered by Darren @ Hak5.org,
Where combining jasager and airdrop-ng can allow you to easily set yourself up as a m.i.t.m transparently, so I began thinking how would you defend against such an attack, with most if not all wifi clients switching to jasager transparently without the user ever knowing, now remember this is all theory at this point it could be completely wrong, please leave feedback in the comments.
before I beging let’s make a couple of assumptions.
- You are the admin for your network
- You are in control of all AP’s on your network
If you can not confirm 1 & 2 then you can land yourself in a whole heap of trouble, so think before you do please …
That said onto a possible defense scenario, making airdrop-ng work as a “shield”.
The main premise of airdrop is to send DeAuth packets forcing a wifi client to reconnect, Darren’s jasager + airdrop podcast (“Airport wifi challenge”) used this in conjunction with jasager to force clients to reconnect but to jasager instead, essentially denying access to the real AP’s and masquerading as them using jasager.
With me so far?
- Client is connected to REAL Access Point
- airdrop-ng sends DeAuth for all BSSIDs except jasager’s
- Client Attempts to reconnect, jasager masquerades as the REAL AP
- Client is now pwned.
To re purpose airdrop-ng as a “shield”, we change step 2 above .
- Client is connected to REAL Access Point
- airdrop-ng sends DeAuth for all BSSIDs except the REAL access point
Now this does cause a problem for any genuine “pop up” wifi, such as the share functionality on mac osx, and mobile hotspots (wifi 3g), but it is one possible method of defense.
If you have some theories related to detecting and defeating WiFi m.i.t.m attacks please let me know, I’d love to hear them,
I’ll work on getting a screencast for this up as soon as possible.
- this will not protect against BSSID / MAC spoofing,
- this will only prevent against a rougue AP BSSID masquerading as your valid AP.
- this will only work within range of your wifi device generating the DeAuth packets.
- improper configuration could cause D.o.S of nearby REAL Ap’s and generaly piss people off.
Update 04/10/2011 Seems that this project wifijammer can do exactly what I outlined above. via: Hackaday
Tags: defense, jasager, mitm
No Comments »
Posted by Buzz in hacking
For some background you may want to read the Original Story leading to this write up.
The first thing that caught my attention was the fact Logwatch was reported login failures in the order of 1000′s from unassigned.psychz.net without an accompanying fail2ban email notifying me the offender had been banned.
And this as it would turn out was because the attack was clearly intended to defeat such protection methods, this is due to the logged host being unassigned.psychz.net, when the authentication failure is logged, a reverse lookup is made within vsftpd to resolve the host this PTR record returns unassigned.psychz.net, and as such is written into the log.
fail2ban no uses regex to extract the host from the logs, and attempts to make a forward lookup on unassigned.psychz.net (A/CNAME records required) to resolve the ip address, and ban the offending ip, this is where things go awry.
psychz.net maintains their own DNS servers,
- DNS1.PSYCHZ.NET
- DNS2.PSYCHZ.NET
These provide a PTR but no A/CNAME record, as such fail2ban can not resolve an IP and the attacking ip is left to run their attack unhindered, see this log file: fail2ban name resolution failure log
The only way therefor to gain the attacking ip was to match the ftp connection times to those of the reported login failures using iptables to log all accesses to ftp, quickly get a count of connecting ip’s using:
1
| grep kernel /var/log/messages | awk '{print $9}' | sed 's/SRC=//' | uniq -c | sort |
A complete log can be found here: iptables.log, and a whois can be found here: whois.txt
Disclosure steps taken:
- 26/07/10 psychz support informed given deadline of 09/08/10 for resolution
- Same day standard reply of “thanks for contacting support we are looking into this” …
- 27/07/0 Attacks continue 173.224.208.0/20 network black holed as a result
1
| iptables -A INPUT -s 173.224.208.0/20 -j DROP |
- 09/08/10 deadline passes without update
- 25/08/10 this blog post published
Tags: brute, force, ftp, psychz
5 Comments »
Posted by Buzz in hacking
Time was when a photo was just a captured moment in time, /end nostalgia
Nowadays though what people do not realize is the shear amount of “extra” information is embedded in “that picture you just uploaded to flikr/facebook/photo bucket” especially if you are uploading from a “smart phone” as more and more people are now.
Most photos now contain GPS data embedded in them, this information will survive a resize / upload process, at the time of writing images tested from Facebook appear to have the exif data stripped out (thumbs up for facebook maybe), and it appears php GD by default replaces all EXIF data with it’s own (bug maybe?).
For non sanitized images however you can discern a wealth of information such as:
- Make of camera
- Model of camera
- Software version
- Unix timestamp of time taken
- DateTime stamp of time taken
- Focal length used
- Shutter speed
- if flash used
And if GPS is embedded:
- Longitude
- Latitude
- Altitude
- GPS timestamp
- Direction facing when photo taken
There is yet more data such as the colour profile used, and image resolutions, in my tests photos taken from my iPhone 4 were within 10 meters of where I was actually standing when I took the picture, and in which direction I was facing when I took them.
So one more thing to note in your applications “data sanity” is to strip EXIF tags from uploaded images, lest your contributors private details be leaked from your application.
For example:
- User uploads photo for competition
- Site uses resized photo on competition page to allow visitor voting
- malicious user, saves image from site (or just uses the copy from thier browser cache), gets gps data from photo
- malicious user now knows exact whereabouts photo was taken aswell as the time.
And it doesn’t have to be a malicious user, it could be anyone/anything, if you want to check your images for EXIF data you can use my tool here: http://www.saiweb.co.uk/tools/exif_data.php
No data is stored, and images are deleted immediately after processing, you use this at your own risk however, if you misuse the tool you accept all liability for the legal action to follow, you have been warned.
Tags: data, exif, gps, jpeg, mining.
No Comments »
Posted by Buzz in hacking, Linux
Most of the time when I review our log watches each morning I become enraged at the number of automated attacks,
But ever so occasional I find one that frankly intrigues me.
Today is just such an occasion where I have had multiple Brute force login attempts, the ingenious part is this attack has been designed to bypass tools such as fail2ban, blockhosts etc, and this is how
- Attack is launched from
- has PTR set for
- Failed login attempts record due to reverse lookup
- There is no A record, attacker maintains their own nameservers for the
- fail2ban notes failed logins, attempts to resolve to an IP but fails, due to missing A record
- Attacker can continue brute force attempts unhindered by being banned
I am still reading into how to counter this and will update this post as I figure out how to work around it, it’s a very sneaky and frankly quiet clever method of working around most automated blacklisting/banning tools.
Update 1:
One method I am trialing is the “log target” feature of iptables, in an attempt to match login failure times to the iptables log, I’ll post back with results.
1
| iptables -A INPUT -p tcp --dport ftp -j LOG |
Outputs
1 2 3 4 5 6 7 8
| Jul 23 11:45:57 132 kernel: IN=eth0 OUT= MAC=<mac addr> SRC=<connecitng ip> DST=<server ip> LEN=64 TOS=0x00 PREC=0x00 TTL=55 ID=47423 DF PROTO=TCP SPT=3865 DPT=21 WINDOW=65535 RES=0x00 SYN URGP=0
Jul 23 11:45:57 132 kernel: IN=eth0 OUT= MAC=<mac addr> SRC=<connecitng ip> DST=<server ip> LEN=52 TOS=0x00 PREC=0x00 TTL=55 ID=45370 DF PROTO=TCP SPT=3865 DPT=21 WINDOW=65535 RES=0x00 ACK URGP=0
Jul 23 11:45:57 132 kernel: IN=eth0 OUT= MAC=<mac addr> SRC=<connecitng ip> DST=<server ip> LEN=52 TOS=0x00 PREC=0x00 TTL=55 ID=46896 DF PROTO=TCP SPT=3865 DPT=21 WINDOW=65535 RES=0x00 ACK URGP=0
Jul 23 11:46:01 132 kernel: IN=eth0 OUT= MAC=<mac addr> SRC=<connecitng ip> DST=<server ip> LEN=63 TOS=0x00 PREC=0x00 TTL=55 ID=38502 DF PROTO=TCP SPT=3865 DPT=21 WINDOW=65535 RES=0x00 ACK PSH URGP=0
Jul 23 11:46:02 132 kernel: IN=eth0 OUT= MAC=<mac addr> SRC=<connecitng ip> DST=<server ip> LEN=52 TOS=0x00 PREC=0x00 TTL=55 ID=32551 DF PROTO=TCP SPT=3865 DPT=21 WINDOW=65535 RES=0x00 ACK URGP=0
Jul 23 11:46:02 132 kernel: IN=eth0 OUT= MAC=<mac addr> SRC=<connecitng ip> DST=<server ip> LEN=52 TOS=0x00 PREC=0x00 TTL=55 ID=59735 DF PROTO=TCP SPT=3865 DPT=21 WINDOW=65535 RES=0x00 ACK URGP=0
Jul 23 11:46:04 132 kernel: IN=eth0 OUT= MAC=<mac addr> SRC=<connecitng ip> DST=<server ip> LEN=66 TOS=0x00 PREC=0x00 TTL=55 ID=23116 DF PROTO=TCP SPT=3865 DPT=21 WINDOW=65535 RES=0x00 ACK PSH URGP=0
Jul 23 11:46:07 132 kernel: IN=eth0 OUT= MAC=<mac addr> SRC=<connecitng ip> DST=<server ip> LEN=52 TOS=0x00 PREC=0x00 TTL=55 ID=40246 DF PROTO=TCP SPT=3865 DPT=21 WINDOW=65535 RES=0x00 ACK URGP=0 |
Update 2: Defeating the hack
Now granted this would be a lot worse had the attacking IP been dynamic, fortunatly in this case it’s not
1
| grep kernel /var/log/messages | awk '{print $9}' | sed 's/SRC=//' | uniq -c | sort |
1 2
| 390 173.XXX.XXX.XXX
4 195.XXX.XXX.XXX |
Ip’s have been masked to prevent anyone complaining or threatening legal action (again) for inferring you should block their ip / network range … and me firing off the obligatory “Well if you policed your own network I wouldn’t have to post this no would I” email,
Maybe I am just being Cynical in my “old” age …
Any how as you may have guess I’m black holing the ip with the 390 connection entries.
Thanks
Being as I spoke to a load of people during the course of this I realy can not remember who contributed what to this solution, so I’ll just have to thank you all let me know if you want a crediting link.
Tags: brute, dissecting, fail2ban, force, hack
1 Comment »
Before you read any further note, I will not be including the original hack file, simply due to peoples stupidity in putting this on a production environment to play with, if you use the code you do so at your own risk, and by reading this blog entry / using the code provided you agree to accept all liability upon yourself for your own actions. Don’t be an idiot.
Around 10 days ago I came across this seemingly innocuous little file.
What I am going to cover in this entry is dissecting the ‘payload’ and not so much the web app in question or methods used to compromise it,
Whereas I will not at this time provide the original file, I will provide you with the md5 and sha1 hashes of the file so you can check it’s not lurking on your systems:
md5: 9ee3e6523d154114460d320477a8665a
sha1: 9c64fecea5620d70a716bbd74f6e89612a4a79c7
The bit we are interested in is the last line of the file:
Were you to run this line you would get

Confused yet? now I can appreciate the thinking behind packing a payload to avoid detection, but in this case the payload is packed 12 times, and no before you ask I did not manually run each returned statement to find this out.
Enter Python-Fu:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
| #!/usr/bin/env python
# saiweb.co.uk payload unpack script 26/05/2010
# copy the eval(gzinflate()) line to payload.raw, place in same directory as this file.
"""
Copyright (C) 2010 Buzz saiweb.co.uk.co.uk
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional Terms as Per section 7
Attribution:
Redistribution/Reuse of this code is permitted under the GNU v3 license, as an additional term ALL code must carry the original Author(s) credit in comment form.
"""
import base64, zlib, re, sys
def main():
print 'Running ...'
f = open('payload.raw')
php = f.read()
f.close()
iteration = 0
while re.search('eval\(gzinflate\(base64_decode\(\'',php):
iteration += 1
print 'Iteration: %d' % iteration
raw = re.sub('eval\(gzinflate\(base64_decode\(\'','',php)
raw = re.sub('\'\)\)\);','',raw)
gstring = base64.b64decode(raw.strip())
php = zlib.decompressobj().decompress('x\x9c' + gstring)
#print payload
#sys.exit()
print php
if __name__ == '__main__':
main() |
Copy the first payload lines into a file named payload.raw, take the above code and copy it into a file named dissect.py.
When dissect.py is run you will get the following output:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| python ./dissect.py
Running ...
Iteration: 1
Iteration: 2
Iteration: 3
Iteration: 4
Iteration: 5
Iteration: 6
Iteration: 7
Iteration: 8
Iteration: 9
Iteration: 10
Iteration: 11
Iteration: 12
<?php
... |
As such you may want to run it using the following command:
1
| python ./dissect.py > r57.php |

And what you will find after unpacking 12 times in total, the “payload” is the r57shell, this script is an information gathering tool and pseudo shell, meaning it will run any command on the host server that php can, providing in most cases ssh esq access to the exploited host, allowing you to do pretty much anything you wanted at this point, some of the features also include /etc/passwd /etc/shadow dumping, aswell as searching for a tirade of common file *.sql* admin* etc, it’s a one stop script for information gathering on a LAMP/WAMP based host.
Defense: modify php.ini to disable eval(), exec, shell_exec and all none essential functions.
And of course, ensure your web apps are patched and up to date as well as the host they are running on.
Tags: dissecting, hack, php, python, r57, r57shell
No Comments »
Posted by Buzz in hacking
Or, as one of my colleagues this morning said, firmware programming which in the literal sense of the word I suppose it is firmware.
I’ve decided as some of my twitter followers may already know to produce a library / framework for the teensy arduino which is available from subversion here: http://svn.saiweb.co.uk/branches/teensy/trunk/ under the GPL v3 license
At the time of writing I have worked through this tutorial on operating an RGB LED.
I’ve taken the examples an reworked them into a re-usable library incorporating a multitude of functions,


Being as I have all the parts to work through the full set of tutorials at pjrc, the library will be first updated to incorporate these examples, once complete I’ll be heading over to the HID programming aspect, and there will be a library for a plethora of “fun” applications
Tags: arduino, library, teensy
No Comments »
|