Posts by Pablo Endres

Creating passwords with bash + perl

I had a couple of scripts working in the back end of an application to create users and set the passwords. So instead of reinventing the wheel I used the ?trusty? useradd.

Until recently one could pass the users password in clear text as a parameter. I assume that someone thought about all the passwords that word saved in history files and decided to change it. The problem is that the used the same parameter but now it expected the password to be encrypted, so it basically stopped working but didn’t generate errors.

After some debugging and some man reading the problem was nailed down, but now I had to generate and encrypt the password. I looked and tried many solutions but the best I could find was the crypt library and decided to access is through perl.  What I liked the most about the solution is that I could use all the same native algorithms that the system has installed.

So lets cut the chase, here are the 5 lines of code needed to get the job done:

salt=$(/usr/bin/mkpasswd -l 8 -s 0)
parameter=”print crypt(config,”\$1\$$salt”)”
encrypted=$(perl -e “$parameter”)
/usr/sbin/useradd -p $encrypted <user>

To create a good salt I used the mkpasswd utility that comes with the expect package (yum install expect).  In this case the $1 is not a variable, but the way of telling crypt to use MD5.

Other valid values for the Glibc crypt are:

ID Method
1 MD5
2a Blowfish (not in mainline glibc; added in some Linux distributions)
5 SHA-256 (since glibc 2.7)
6 SHA-512 (since glibc 2.7)

For more information http://www.kernel.org/doc/man-pages/online/pages/man3/crypt.3.html or simply: man crypt

Have fun

3 strikes

I’ve following and ranting on the music and video industries and their 3 strike strategy for a while now. This is an attempt to maintain the status quo in a business that hast to evolve to meet the market (their users) need.

I believe that the way Audio and Video rights are managed should be changed and a new model has to be built.  I’m not good with economy or an MBA,  but I am a user that really hates some of the limitations that are still built into a contents users life.

Let me put an example with the access to English spoken TV in Europe.  There is a great source for it in the UK, there you have access to SKY, BBC and other cable or pay TV services.  If I want to access those services from Germany, you can’t.  You can’t purchase the services, at least not legally (one can only purchase the services with a billing address in the UK).  With today’s interconnected world, these are the type of things that send people to look for alternative ways to access those contents.  So in a way the excessive controls are sending people to go to and find alternative ways to acces the contents that they can’t access or purchase through traditional channels.

I like the approach taken by Amazon in the US where you can by your favorite content and have instant access to whatch it through streaming, you can download it a specific number of times (4 if I remember correctly) in different formats: HD, MPEG or a smaller version for your IPOD.

I’m just glad that at least for now the 3 strike law in France was suspended.   And hope that  new cross European solutions see the light, because being able to whatch TV in your own language definitly helps people to feel at home away form home.

Photo credit: “And You’re Outta There!” originally uploaded by Chad Horwedel

ISECOM TtT

I managed to get a few days away from the day job to attend the ISECOM Train the Trainer event in Barcelona (27-29 May) and it was really a great experience.  Being that the event was for the certified or to be certified trainer crowd it was pretty intense and at the end of the last day my brain was jello.

Jello Brain

Jello Brain

It was great to finally meet Pete Herzog, who I had the pleasure of working with before on the Hacking Expossed book.  I also got time to meet some of other European trainers, and it’s a good batch  😉

I got to take the OPSA and OPST exams, the results should be due any time now.  I really liked the format of both cert exams: hands on!  For the OPST you have to shoot at a couple of live test systems to complete the results you need, and for the OPSA there is a little theory on the OSSTM, some shooting to be done but most of all analysis (hence the A in OPSA).  I fried my brain on the last question, I didn’t notice at the begining that it was a packet dump that needed to be analyzed.  So after 8 hours of class the 2.5h I took to complete the exam were the last effort.

For those of you who have no idea of what I’m talking about, you can find information on the OSSTM at http://www.isecom.org/

GnomeKeyring =? ssh-agent

This feature just popped up and started working after I upgraded to Fedora 10 and I though it was a standard function in gnome, but I was working with Per the other day and his Ubuntu 8.04 didn’t have it running out of the box.  So I had to take a look a the docs to make it work:  http://live.gnome.org/GnomeKeyring/Ssh

This is just one of those features that make your life easier but handling all the ssh sessions for you, the best part is that is one of those setup once and forget feature.  Here is a brief introduction on how it works:

According to the ssh-agent man:

     ssh-agent is a program to hold private keys used for public key authenti-
     cation (RSA, DSA).  The idea is that ssh-agent is started in the begin-
     ning of an X-session or a login session, and all other windows or pro-
     grams are started as clients to the ssh-agent program.  Through use of
     environment variables the agent can be located and automatically used for
     authentication when logging in to other machines using ssh(1).

So what gnome did was include an ssh-agent in the gnome-keyring(-daemon), so it has one interface to manage passwords, ssh keys, etc.  Underneath the hood this is how it works:

  1. When Gnome starts the gnome-keyring-daemon (if it is enabled in your conf)
  2. The keyring manager starts the ssh-agent component and sets up the SSH_AUTH_SOCK variable, that will redirect ssh to make the queries to that socket
  3. The SSH agent automatically loads files in ~/.ssh having names starting with id_rsa or id_dsa or any other keys included by using the ssh-add command

That does the job.  If you need to get it working on your Gnome installation follow the instructions here.

Transpose Open Office Calc data from rows to columns, or vice versa

I had to shift through a ton a data today and after I was have way through I realized that I would be easier to express and analyze the data if it was transposed o just filled in the other way around (rows and columns).  On any other day or a different stage of the work I would have retyped it, but I got lazy and found this link and all you have to do is a special paste and check the transpose box.

Incredible!

The best thing is that it works both in M$ Office and Open Office.

Updated 2013/09/04:
As reader Blub kindly pointed out, the link I had was dead so, here is the information directly

  1. Select the range of cells containing the data that is to be transposed.
  2. Click Edit and select Cut.
  3. Select a cell in the spreadsheet that the table will start.
  4. Click Edit and select Paste Special.
  5. In the Options section, check the Transpose checkbox.
  6. Click OK

Additionally here are some links if you want to see the screen shots:
MS Office or Open Office Calc

 

Merging PDF files

Have you ever scanned a pile of documents on a “non enterprise” o home scanner, or just got distracted when using the big Xerox machine in the office.  You’ll end up with a ton of individual pdf files.  After a little google and man reading I found these 2 solutions.

  1. On linux just use pdfmerge:   sudo yum install pdfmerge or download the windows version
  2. Do it by hand with ghostscript:

gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=finished.pdf Scan001.pdf Scan002.pdf

snmp errors in syslog

I finally got fed up of these messages in my log files (/var/log/messages) and decided to do something about them:

Apr 19 04:14:47 hostname snmpd[3458]: Connection from UDP: [127.0.0.1]:42482
Apr 19 04:14:47 hostname snmpd[3458]: Received SNMP packet(s) from UDP: [127.0.0.1]:42482

After reading, googling around and testing for a while I rounded it the following solution, it should work in any Linux system with net-snmp after some tweaks but out of the box on CentOS, REL, Fedora or any of its relatives:

1. Remove the -a from the snmpd start options or write this in the /etc/sysconfig/snmpd.options file:

OPTIONS=”-Lsd -Lf /dev/null -p /var/run/snmpd.pid”

This should take care of the “Received SNMP” packets line (2nd one).

2. Add dontLogTCPWrappersConnects true at the end of your /etc/snmp/snmpd.conf file, that takes care of the other line:

Apr 19 04:13:47 dcf-is1p snmpd[3458]: Connection from UDP: [127.0.0.1]:48911

According to the man page: This setting disables the log messages for accepted connections. Denied connections will still be logged.”

The problem is that the default settings are to log every connection / request, so what we did was leave the log work only for failed and authenticated attempts

Enjoy readable logs!

Windows FTP client passive

Have you ever tried to connect to an ftp server on a windows box?

I had to do it today and that thing doesn’t know the command: PASV !!

Well after surfing for while I found the workaround: just type:

LITERAL PASV

That bypasses the checks on the client and just sends the command to the server.

picasa and Fedora 10

It’s really been a while since a sent my last update with pictures of what I’ve done.  I normally try to keep friends and family up to date on what I’ve been doing since I moved to the other side of the Atlantic (to the European side).  So today I fired up picasa to get the web albums up2date and nothing happend.  When I ran it in a shell this came out:

[host]:/home/epablo:>picasa
/usr/bin/picasa: line 139: 25634 Segmentation fault      “$PIC_BINDIR”/wrapper check_dir.exe.so
/usr/bin/picasa: line 175: 25734 Segmentation fault      “$PIC_BINDIR/wrapper” regedit /E $registry_export HKEY_USERS\S-1-5-4\Software\Google\Picasa\Picasa2\Preferences\

After googling for I while I didn’t find any reasonable explanation for the error.  I did find a beta (comming from google what could I expect) repository (here are the instructions on how to set it up) and upgraded from picasa-2.7.3736-15 to picasa-3.0.5744-02

It started up, I’ll keep you posted on how it goes with the field try..

VMware Workstation 6.5.0 + fedora 10

So I upgraded to Fedora 10 and my VMWare stoped working as expected and comented on my last post.

After testing, playing and surfing for I while I found this post which gave me some ideas.  This his how I got it working:

TERM=dumb /usr/bin/vmware-modconfig –console –install-all –icon=/usr/share/icons/hicolor/32×32/apps/vmware-workstation.png –appname=”VMware Workstation”

So have fun

Prev134566Next