Showing posts with label security. Show all posts
Showing posts with label security. Show all posts

Wednesday, February 1, 2012

Tenable SC4 Asset Groups From AD

Note (5/8/12): With the latest release of Tenable Security Center 4.4.x, you can create asset groups using DNS names.

If you are a Tenable Security Center 4 user, you might have noticed that unlike Qualys, you can only use IP addresses in SC4 asset groups**.  In normal production environments, IPs are static and this restriction does not pose a huge challenge.  However, in my case we are using SC4 to scan a large end-user desktop environment which is using AD Dynamic DHCP.  Due to this, I find myself having to update the asset groups before a scan and it can be tedious.

To make things easier, I decided to write a quick 'n' dirty shell script to get the computer names from AD and do a reverse lookup.

#!/bin/sh
LDAPURI="ldap://corp.ldap.server"
USER="user@domain.com"
echo "LDAP Password:"
read PASS
DEPT=([1]="Dept 1" [2]="Dept 2" [3]="Dept 3")

for ((i=1; i<=${#DEPT[@]}; i++ ));
do
        CMD="/usr/bin/ldapsearch -x -v -LLL -E pr=200/noprompt -H $LDAPURI -D \"$USER\" -w $PASS -b \"OU=${DEPT[$i]} Computers,OU=${DEPT[$i]},OU=Corporate,DC=domain,DC=com\" -s one \"(objectClass=computer)\" | grep name | awk '{print \$2}' | tr '[:upper:]' '[:lower:]' | sed 's/$/.domain.com/' | dig +short -f -"

        echo "Run $CMD:"
        eval $CMD > ${DEPT[$i]}_IPs.txt
done


The resulting output should be one file per department containing IP's of all the names which resolved.

Note: I am doing a simple LDAP bind (-x) and the password (-w) is sent clear-text.

** I have been told by my Tenable sales rep that in late Feb 2012 they *might* include the ability to add hosts using DNS name.

Thanks,
VVK

Tuesday, October 25, 2011

thc-ssl-dos on Backtrack 5

If you are trying to install the thc-ssl-dos on BackTrack 5, you might run into the issue of outdated libssl libraries (requires libssl-dev).

Host: i686-pc-linux-gnu
          Compiler: gcc
    Compiler Flags: -O2 -Wall
Preprocessor flags:  -I/usr/local/include -I/opt/openssl-1.0.0e/
      Linker flags: -L./  -L/usr/local/lib -L/opt/openssl-1.0.0e/
         Libraries: -lssl -lcrypto -lnsl
WARNING: OPENSSL LIBRARIES ARE TO OLD! UPDATE THEM!\n
WARNING: OPENSSL LIBRARIES ARE TO OLD! UPDATE THEM!\n
WARNING: OPENSSL LIBRARIES ARE TO OLD! UPDATE THEM!\n

To get around these warnings, you can simply grab the latest copy of openssl, build, and then point thc-ssl-dos configure script to use the latest libraries.

$ tar -xvzf openssl-1.0.0e.tar.gz
$ cd openssl-1.0.0e
$ make
$ sudo mv ../openssl-1.0.0e /opt/
$ cd ../thc-ssl-dos-1.4
$ ./configure --prefix=/opt/thc-ssl-dos --with-includes=/opt/openssl-1.0.0e/include/ --with-libs=/opt/openssl-1.0.0e/
$ make
$ sudo make install

THC-SSL-DOWN has been configured with the following options:

              Host: i686-pc-linux-gnu
          Compiler: gcc
    Compiler Flags: -O2 -Wall
Preprocessor flags:  -I/usr/local/include -I/opt/openssl-1.0.0e/include/
      Linker flags: -L./  -L/usr/local/lib -L/opt/openssl-1.0.0e/
         Libraries: -lssl -lcrypto -lnsl

       Debug build: No
Configuration complete. Now type: make all install

$ cd /opt/thc-ssl-dos/bin
$ ./thc-ssl-dos
     ______________ ___  _________
     \__    ___/   |   \ \_   ___ \
       |    | /    ~    \/    \  \/
       |    | \    Y    /\     \____
       |____|  \___|_  /  \______  /
                     \/          \/
            http://www.thc.org

          Twitter @hackerschoice

Greetingz: the french underground

./thc-ssl-dos [options]
  -h      help
  -l   Limit parallel connections [default: 400]


Cheers,
VVK



Tuesday, May 24, 2011

Windows XP Firewall All Ports IP Exception

Windows XP is no longer officially supported by Microsoft, but that does not mean it has cease to exist in the enterprise. With SP2, Microsoft introduced a built in firewall (and I use that term loosely) which improved security (compared to pre-SP2).

For whatever reason, Microsoft decided to not offer the ability to simply specify a port range. Each specified rule can be related to a service or a port/protocol combination. This might not seem like a major hurdle, until you come across a specific need such as vulnerability scanning.

I recently ran into this issue where I needed to make an exception for a specific vulnerability scanner IP for all port/protocol combinations on a Windows XP machine. Disabling the firewall was not an option because the target network of Windows XP hosts is in a high risk environment and to make matters worse, the users have administrative privileges.

There are two solutions to this problem, you can either run a for-loop and insert your firewall rules, or you can update the %windir%\Inf\Netfw.inf file.

For-loop Approach

Run the following using a script of command-line:
FOR /L %I IN (1,1,65535) DO netsh firewall add portopening protocol = ALL port = %I name = scanner mode = ENABLE scope = CUSTOM addresses = 10.10.12.101/32
Disclaimer:
The result of this command is 131070 lines of firewall rules, all named 'scanner'.  Also, it will take a long time for this command to run.

Based on my test on a VM (1 x 1.6 GHz, 512 MB), I was able to process 66 rules per minute.  So it will take approximately 16 hours to insert all 131070 rules!  :-O

Netfw.inf Approach 

Windows XP firewall has two modes, domain and standard.  Depending on your use scenario, add a variation of the following lines under the appropriate section:
HKLM,"SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\DomainProfile\GloballyOpenPorts\List","port number:protocol",0x00000000,"port number:protocol:scope:mode:port’s friendly name"
port number – A port is specified by the combination of a protocol and a port number. The port number must be between 1 and 65535 inclusive.

protocol – A port is specified by the combination of a protocol and a port number. The protocol must be either TCP or UDP. 

scope – Permitted values for scope are defined the “Defining the Scope for an Entry in the Windows Firewall INF File” section of this article.

mode – An entry can be added to Windows Firewall’s default exceptions lists as either enabled or disabled. The two permitted values for this element are enabled and disabled. If a port’s entry is enabled, the port will be statically opened in Windows Firewall. If a port’s entry is disabled, the port will not be statically opened in Windows Firewall.

port’s friendly name – This is the description that will be used to represent the entry in the Windows Firewall Control Panel applet. It should provide an indication of why the port is statically opened, such as "Web Server (TCP 80)" or "Telnet Server (TCP 23)".
 
Here is a simple python script to help you generate your firewall rules.  Rules are written to 'fw.txt'.  Copy the lines and paste them under the appropriate profile in %windir%\Inf\Netfw.inf.

To apply the changes, run:
netsh firewall reset
Note: This will take a very long time.

You can verify your rules by running:
netsh firewall show config

Cheers,
VVK

Tuesday, December 28, 2010

Star Trek Word List

While experimenting with Fierce I needed a Star Trek word list to conduct a brute force DNS scan.  The free word lists available from Oxford University repository are a good start but there seems to be room for improvement.  I found the Star Trek world list (Trek.Z) severely lacking (530 entries), so decided to populate my own list with help from Wikipedia.  In my case I am interested in Star Trek ship and captain names (for this particular test lab) which were absent from Trek.Z file.  With some ghetto awk,sed,grep and cut action, I populated a list with names of all the Star Trek ships, characters and the names of the actors.

You can download my Star Trek word list (1581 entries) from here.


HTH.
VVK

Wednesday, December 22, 2010

Data Security Breach Statistics

I am currently working on putting together a security training curriculum for my employer.  I needed to do find some reliable statistics regarding number of data breaches, total records lost etc. pertaining to my employers industry.  I found three good resources for such statistics:
  1. Privacy Rights Clearinghouse
  2. DataLoss DB
  3. Identity Theft Resource Center
Of course, one the best resource is the Verizon Data Breach Investigations Report.

Update 7/22/2011
If you need to estimate approximate cost associated with a data breach, a good starting point is Symantec's Data Breach Calculator (in partnership with Ponemon Institute).

HTH,
VVK

Wednesday, December 1, 2010

CLI Interactions w/SSL Enabled Website

I found it amusing that one of the major changes in the new PCI 2.0 regulation requires that any vulnerabilities with a CVSS score > 4 must be remediated (6.2).  It is amusing because what good does it do to require companies to perform vulnerability scanning, if remediation is not enforced, which was the case with the previous version of PCI DSS (11.2).

I digress.  Often I am required to confirm an identified vulnerability or validate a fix for a web server.  For example, checking to see if TRACK/TRACE is enabled/disabled or HOST header is set for name based virtual hosts.  These checks are easy to perform on a non-SSL web server (HTTP) using Telnet, but Telnet cannot be used against an SSL enabled web server (HTTPS).

# telnet ssl.somehost.com 443
Trying 10.10.3.93...
Connected to ssl.somehost.com.
Escape character is '^]'.
GET / HTTP/1.1
Connection closed by foreign host.

Telnet-SSL
The connection fails because telnet lacks SSL support.  You can verify this on Linux using the ‘ldd’ tool.
# ldd /usr/bin/telnet
        linux-gate.so.1 =>  (0xffffe000)
        libncurses.so.5 => /lib/libncurses.so.5 (0xb76c8000)
        libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0xb75da000)
        libm.so.6 => /lib/tls/i686/cmov/libm.so.6 (0xb75b3000)
        libgcc_s.so.1 => /lib/libgcc_s.so.1 (0xb75a4000)
        libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0xb744a000)
        libdl.so.2 => /lib/tls/i686/cmov/libdl.so.2 (0xb7446000)
        /lib/ld-linux.so.2 (0xb7711000)

The good news is that there is an SSL enabled version of telnet, called  telnet-ssl (netkit-telnet-ssl).  In the following examples, I am using the BackTrack 4 distribution.

# apt-get install telnet-ssl
# ldd /usr/bin/telnet
        linux-gate.so.1 =>  (0xffffe000)
        libncurses.so.5 => /lib/libncurses.so.5 (0xb76cb000)
        libssl.so.0.9.8 => /usr/lib/i686/cmov/libssl.so.0.9.8 (0xb7684000)
        libcrypto.so.0.9.8 => /usr/lib/i686/cmov/libcrypto.so.0.9.8 (0xb7537000)
        libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0xb7449000)
       [snip]

# ls -l `which telnet`
lrwxrwxrwx 1 root root 24 Dec  1 10:48 /usr/bin/telnet -> /etc/alternatives/telnet
# ls -l /etc/alternatives/telnet
lrwxrwxrwx 1 root root 19 Dec  1 10:48 /etc/alternatives/telnet -> /usr/bin/telnet-ssl

# telnet -z ssl ssl.somehost.com 443
Trying 10.10.3.93...
Connected to ssl.somehost.com.
Escape character is '^]'.
GET / HTTP/1.1
HOST: ssl.somehost.com
HTTP/1.1 200 OK
Content-Type: text/html
Last-Modified: Thu, 11 Nov 2010 15:08:59 GMT
Accept-Ranges: bytes
Server: Microsoft-IIS/7.5
Date: Wed, 01 Dec 2010 17:07:40 GMT
Content-Length: 519

[snip]

Metasploit
Another alternative to installing netkit-telnet-ssl is to use Metasploit itself.  Of course Metasploit might be an overkill if all you want to do is perform simple tests like the one above.  In the case of BackTrack 4 distribution, Metasploit comes installed by default. 

msf > connect -s ssl.somehost.com 443
[*] Connected to ssl.somehost.com:443
GET / HTTP/1.1
HOST: ssl.somehost.com
HTTP/1.1 200 OK
Content-Type: text/html
Last-Modified: Thu, 11 Nov 2010 15:08:59 GMT
Accept-Ranges: bytes
Server: Microsoft-IIS/7.5
Date: Wed, 01 Dec 2010 17:07:40 GMT
Content-Length: 519

[snip]

If you know of any standard tools on Linux and Windows or any 3rd party tools for Windows, which can do the same, please leave a comment.

Cheers,
VVK

Friday, July 30, 2010

SSL/TLS Weak Cipher

While reviewing a Qualys report, I noticed the following "QID: 38140 SSL Server Supports Weak Encryption Vulnerability".  Of course one can verify Qualys findings one cipher at a time using openssl, but in order to verify all supported cipher-MAC combination, I needed to find an automated tool. Here are some of the useful ones I found:
  1. Qualys SSL Labs - Good choice if you need to generate a presentable report for management.
  2. CryptoNark - In addition to checking SSL Ciphers, it also does HTTP Track/Trace check and 'Unsafe' URL check.  You will need to install some custom Perl modules to get it working.
  3. SSLscan - Comes bundled with BackTrack4.
It is a lot easier to quickly verify your remediation using these tools, as opposed to submitting another Qualys scan.

Update (6/21/11): Here is a new tool from Leviathan Security to help test SSL Re-negotiation vulnerability. (also see "(Really) Testing for SSL/TLS Re-negotiation")

Cheers,
VVK

Tuesday, May 4, 2010

Microsoft's Adobe PDF Woes

In recent months, Adobe's Acrobat reader has become an attractive target on Microsoft Windows platform.

I stopped using Acrobat reader on my Windows hosts a while back when I realized that Acrobat reader is 38 MB in size, compared to 1.2 MB SumatraPDF (Open Source), 6.7 MB Foxit Reader (Closed Source), and online Google Docs.

Here I am assuming that the size of the Acrobat Reader directly correlates with the number of lines of code, and studies have shown a direct relationship between the number of lines and number of defects.

"Commercial software typically has 20 to 30 bugs for every 1,000 lines of code, according to Carnegie Mellon University's CyLab Sustainable Computing Consortium. This would be equivalent to 114,000 to 171,000 bugs in 5.7 million lines of code" (Linux: Fewer Bugs Than Rivals )

I consider myself a very heavy PDF user, and it is extremely rare for me to need features such as Javascript functionality, Assistive technology, various third party plugins etc. built into Acrobat Reader.

F-Secure's Sean Sullivan recently urged Microsoft to integrate some type of PDF preview option and spare its users from having to install Adobe Acrobat Reader. I could not agree more with Mr. Sullivan. It is about time Microsoft learned a lesson from Gnome (Evince) and KDE (Okular) and provided a bundled basic PDF viewer as part of the OS.

My 2 cents.
VVK

Wednesday, April 28, 2010

Shifted Password Strategy = Simple Obfuscation


Recently Adam Pash posted an article on lifehacker titled “Shift Your Fingers One Key to the Right for Easy-to-Remember but Awesome Passwords”. The basic idea behind this trick is to generate what appear to be complex passwords by merely placing your fingers one key to the right and typing something easy to remember. For example, “Password” would become “{sddeptf”.

Due to a lack of a better term, I will call this approach “Shifted Password” in this post.

Initially I thought Shifted Password was a great idea, and I wondered if it is a better and simpler approach to the one proposed by Bruce Schneier’s in his Wired article titled “Secure Passwords Keep You Safer”. However after careful consideration, I have come to the conclusion that Shifted Password approach is neither practical nor secure.

Practicality
People are no longer accessing their password protected resources using only a laptop/desktop with a full size keyboard. The use of alternative input mechanisms and variations in keyboard layout (iPhone, Blackberry, Dvorak etc.) renders Shifted Password strategy ineffective.

Security
Although passwords generated using Shifted Password strategy might appear to be strong (more complex), the fact is Shifted Password is merely an obfuscation of a simple password (easy to remember). In other words, shifted password is not a good substitute for a complex password.

For example, if someone wants to use "myDogSpot” as the password, the Shifted Password version would look like “,uFphD[py”. Looks secure! But is it? The fact is it is still vulnerable to a dictionary brute force attack. These attacks might not be common yet, but it is a matter of time till the attackers smarten up and modify their attack strategy to include this obfuscated variation.

Over at Command Like Kung Fu blog, they already have a post titled "Shifty Passwords” which shows how easy it is to compensate for this obfuscation using unix tr command and generate a new shifted version dictionary based on an existing dictionary.

$ cat dict.txt | tr "$r1$R1$r2$R2$r3$R3$r4$R4" "$r1s$R1s$r2s$R2s$r3s$R3s$r4s$R4s" >shift-dict.txt

Conclusion
In the lifehacker article, Adam Pash concludes:

"
Something longer but still really lame, like, say, "topsecretpassword", becomes "yp[drvtry[sddeptf". These may not be perfect compared to secure password generators, but they're likely orders of magnitude better than a lot of people's go-to passwords."

I would humbly disagree with Adam, because I think that the appearance of complexity could fool a user into a false sense of security. I think claiming that Shifted Password approach is "magnitude better" is a bit of a false advertisement.

If you are willing to accept the practical limitation of Shift Password strategy, it could prove to be useful, granted that you use a complex password to start with (catch 22!).

In my book, I am going to score this as Bruce Schneier 1, Adam Pash 0. :-)

Cheers,
VVK

Saturday, December 12, 2009

Minimal Postfix (SMTP only)

While configuring Aide on a standalone system, I needed to configure SMTP in order to receive the cron job output. In absence of a mail gateway server willing to relay, I was left with the only option of running a local SMTP daemon. I installed Postfix and noticed that by default it runs on loopback interface and starts approximately 83 processes.

[root@localhost postfix]# netstat -ap | grep master | wc -l
83

I didn't really need all the additional Postfix features, so I set out to configure the bare minimum setup.

After spending some time going through the /etc/postfix/master.cf file, and some trial and error, I managed to narrowed the configuration down to the following:

smtp inet n - n - - smtpd
pickup fifo n - n 60 1 pickup
cleanup unix n - n - 0 cleanup
qmgr fifo n - n 300 1 qmgr
tlsmgr unix - - n 1000? 1 tlsmgr
rewrite unix - - n - - trivial-rewrite
smtp unix - - n - - smtp

Now, Postfix starts up only 20 processes.
[root@localhost postfix]# netstat -ap | grep master | wc -l
20

Note: Mail sent using such a setup is most likely to end-up in your spam folder.

Cheers,
VVK

Saturday, December 5, 2009

Unintrusive RPM Distro Audit

As a consultant, I am often faced with an unfamiliar Linux system (usually RHEL). I always find it useful to understand which files that shipped with rpm packages have been modified, since it is usually a good indicator of what customizations have been performed on the system. To determine the modified files, I simply run:

% rpm -qa | xargs rpm --verify --nomtime | less

# Sample output:

missing /usr/local/src
.M...... /bin/ping6
.M...... /usr/bin/chage
.M...... /usr/bin/gpasswd
....L... c /etc/pam.d/system-auth
.M...... /usr/bin/chfn
.M...... /usr/bin/chsh
S.5..... c /etc/rc.d/rc.local
S.5..... c /etc/sysctl.conf
S.5..... c /etc/ssh/sshd_config
S.5..... c /etc/updatedb.conf

The following is taken from the rpm man pages (Verify Options section):

c %config configuration file.
d %doc documentation file.
g %ghost file (i.e. the file contents are not
included in the package payload).
l %license license file.
r %readme readme file.

S file Size differs
M Mode differs (includes permissions and file type)
5 MD5 sum differs
D Device major/minor number mismatch
L readLink(2) path mismatch
U User ownership differs
G Group ownership differs
T mTime differs

Using this trick, I can quickly determine what configuration files have been modified as well as any metadata modifications (ownership, link etc.).

Cheers,
VVK