Jul 202011
 
How to find all executable files:


find / -type f -perm -o+rx

This can take quite a while, so you may want to pipe the results to less so you can search in them or instead of root directory to use /bin or /usr/bin.

How to automount USB memory stick devices with user rights.

Edit the line in /etc/group saying “plugdev” with your user name:

plugdev:x:83:root,yourusername

This way every time there is new USB device plugged in the system, you will see a new Icon on your desktop with its name and size. You need to restart udev as root by writing:

sudo /etc/rc.d/rc.udev reload
sudo /etc/rc.d/rc.udev restart

How to change DOS/Windows CR+LF to Unix (dos2unix)

If you don’t have this utility, use the following:

perl -pi -e 's/\r\n/\n/;' DosFilename.txt

How to strip configuration lines from the prompt

Imagine you have a switch configuration example like this:

DUT(config)#system monitor
DUT(config-monitor)#cpu-temperature
DUT(config-cpu-temperature)#log
DUT(config-cpu-temperature)#trap
DUT(config-cpu-temperature)#low-threshold 10
DUT(config-cpu-temperature)#no shutdown
DUT(config)#log ssh-console severity debug
DUT(config)#commit

You need only the configuration lines, without the prompts, so you easily copy&paste them later, when you need to set the switch. Executing this command and pasting results *(or piping them) will strip everything in left of the pound sign (including the sign):

cat | awk -F"#" '{ print $2 }'
or:
cat copied_manual.txt | awk -F"#" '{ print $2 }'

How to decode text to ascii codes for SNMP

Sometimes, walking an SNMP table may show you the following lines:


dot1agCfmMdRowStatus.7.100.111.109.97.105.110.53

This OID line is quite straight forward until the digits. Dot1ag means the standard 802.1ag (OAM CFM) and the status of the maintenance domain. For some reason the remaining text is in ASCII + char length. 7 is char length and the remaining ASCII codes mean “domain5”. I wrote some Perl script to convert strings to dot-digit format for this:

#!/usr/bin/perl -w

if (! $ARGV[0]) {die "There are no args";}

print $ARGV[0];
print " is equal to ";
@ascii_character_numbers = unpack("C*", $ARGV[0]);

print scalar(@ascii_character_numbers);

foreach (@ascii_character_numbers) {
    print ".";
    print $_;
}

print "\n";

Usage is:

unascii.pl testtest
testtest is equal to 8.116.101.115.116.116.101.115.116

Check the next tricks article too 😉

 Posted by at 10:03 am
Jul 152011
 

Slackware Linux uses udev to decide how to manage the recognized devices in your /dev/ directory. Also any hotplug devices are also handled by udev for loading the appropriate kernel modules and create(or enable) a /dev node for mounting purposes. Udev is doing quite well, except in 2 cases:

  • You need eth1 to actually be eth0 and eth2 to become eth1.

This is one of the cases, in which you have e.g. 1GBps NIC and want it to be exactly eth0 and 2 more that you need for your home network set. You already have the scripts to create NAT and they point to eth0 by default. It’s faster to switch NIC names than to rewrite the scripts.

  • Your motherboard died and you want your hard drive moved to another system so you keep working.

In this case, most if not all the new motherboard components will be recognized by udev but there will be one difference in one specific file at /etc/udev/rules.d/ this file is called 70-persistent-net.rules and is responsible for mapping the network cards by their manufacturing address (MAC address).

The file looks like this:

# PCI device 0x10ec:0x8139 (8139too)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:40:95:30:c5:7e", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# PCI device 0x10ec:0x8139 (8139too)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:06:4f:29:49:f0", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

# PCI device 0x10ec:0x8139 (8139too)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:01:6c:e2:ff:d2", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2"

And if you want the NICs remaped, the only thing that needs to be done is to set the option NAME in the end of each line to whatever you want your NICs to be set. This is about the first scenario.

The second scenario, when you place the hard drive to a new system with similar configuration, you will see the udev will actually displace the NICs. If your old system had eth0, eth1 and eth2 – now your system will have eth3, eth4 and eth5. Old/original NICs places will be kept (as if your broken machine will revive 😉 hahaha 😀 )

You need to set them back to point to eth0, eth1 and eth2 and no system reconfiguration will be needed (except in the case where your Video card is different, than you need to reconfigure X.org).

That’s basicly it. Modify /etc/udev/rules.d/70-persistent-net.rules and restart the udev process.

bash-4.1# /etc/rc.d/rc.udev restart

The next step is to make your configuration go back to what it was. It’s actually one command only if you have not changed anything else:

bash-4.1# /etc/rc.d/rc.inet1 restart

That way, your network should be back to what it was.

 Posted by at 6:00 pm

The need of secured e-mail.

 Netw0rking  Comments Off on The need of secured e-mail.
Jul 132011
 

What do you do when you register in such networks as Facebook or Twitter.

You enter an e-mail.

Where do you have your “recover password” set for most of the accounts you use?

You enter an e-mail.

Where do you receive your payments and fiscal reports?

On your e-mail.

Alarmed?

You should at least be aware.

Having your e-mail compromised can lead to tons of problems.

Most of the social networks are providing too much information about yourself. Like your GF/BF/Pet name. Your interests. Your kids’ names. Your favourite books. How often do you contact a person (your best friend) and more.

It’s not that hard to guess your password from your interests and family. Believe me. It’s valid even for me. And from that point on, the bad person that wants your account information, can activate at all your sites of interest the “forgoten password” mechanism and change all your passwords to something else. Steal all your money. Know all your secrets. Download all your private data and use it as s/he sees fit. Just by guessing your e-mail password.

Lately one of my friends allowed his password to be guessed by a hotel picollo. He got all his credits in Texas Hold Them Poker game –  lost. 80 millions. Don’t know how long it takes to collect that much… His pasword was his GF name.

The point is… Simply protect your weakest point the best way you can.

If you have ONE e-mail for all purposes, the password should be something really hard and strong. Something even your best friend can’t guess. And even if s/he can… not entirely guess it by the letter.

Suppose you are Clifford D. Simak fan to the grave and adore the “City” the way I did in my youth. Suppose you set your password to be “jenkins”? It’s actually too short. And you probably put your nick name in most of the games you play to be also “jenkins”. Not too short would be jenkinstherobot. But it will also be quite guessable. If not by an actual no-good-doer, it should be easily guessed by anyone that knows you, what you read, what you prefer and what inspires you.

If you are dedicated to your girfriend or your kids or your best friend, it’s still easy. They will first try first names, than senior names, than family names, than all 9 combinations of them with and without spaces. Than with and without capital letters. And believe me. That’s merely 81 combinations.

Today’s normal dictionary attack makes this for a fraction of the second. Your password is weak if it is pure text. And this is valid for ALL your accounts. Not just your master e-mail.

Period.

Good password would be anything that consist of capitol and normal letter and digit or digits. Examples:

  • I_l()ve_Jan3
  • J3nk!nsTh3R0b0t
  • Az!m0vRulzz
  • M0rdr3dAndM0rgana
  • MyL!feF0rAiur
  • \/f0rVend3tta

etc.

In all cases – don’t use weak passwords in an account that can compromise other accounts. It’s imperative. A friend of mine made another blog post in Bulgarian regarding the needed e-mail security. You may want to check his blog post if you are Bulgarian. The diagram in the post heading is quite true and easy to remember. I’ve taken some ideas from his post and the talks with him too. One of the ideas for good password is to make a word, that has nothing to do with ANY dictionary on the planet but is still very easy to remember. Imagine the sentence “I very much enjoy drinking beer while chewing sausage with my friends in the pub at eight”. Now concatenate all the words to 1 letter each. The password becomes:

  • Ivmedbwcswmfitpa8

Guess that password with or without dictionary attack or with brute force and I will buy you a beer… and a sausage 😉

 Posted by at 11:44 pm