parsed.org

Tips by tag: security

Adding Users with Passwords by xinu on Sep 10, 2005 12:13 AM

BSD is a little paranoid about where your passwords come from, so they'll insist on getting it from a stream. Here's an example:

(edit the file '/tmp/pass' and deposit the password there)            
% su root -c sh
Password:
# pw useradd -n test -c "Test User" -m -h 3 3< /tmp/pass
# grep test /etc/master.passwd
test:$1$T2tu0BET$UGPrNB1FavzjlzhTwUWRN.:1002:1002::0:0:Test User:/home/test:/bin/sh
# exit
% su test
Password: [typed "foobar" here...]
$ exit
bsdcommandsfreebsdneatparanoidpasswordspwsecurity
Changing Process Priority by xinu on Mar 10, 2005 01:52 PM

Ever been on a machine that was ailing and just wouldn't respond? As soon as you're root, lower the priority of the offending process ID(s) (in this example, 1103) by using the 'renice' command:

# renice -19 1103
commandsconfigurationcontroldebuggingmonitoringpriorityprocessrecoveryrenicerescuesecurityshell
Decrypt RSA Key by xinu on Sep 10, 2005 12:15 AM

Tired of typing your SSL password on boot of your webserver? You can decrypt it if you're certain it's safe:

# openssl rsa -in server.key -out server.key.unsecure
apachebootcommandsencryptionkeyopensslsecurityshellsslwebserver
Generate a Self-Signed SSL Certificate by cygnus on Apr 11, 2005 07:54 AM

Use these commands to generate a self-signed SSL certificate (e.g. for Apache):

# openssl genrsa 1024 > server.key
# openssl req -new -key server.key -x509 -days 90 -out server.crt
apachecertificatescommandskeysopensslsecurityssl
Generating Strong Passwords by cygnus on Apr 05, 2005 10:35 AM

Use the apg utility to generate strong mnemonic passwords:

$ apg -st

Please enter some random data (only first 8 are significant)
(eg. your old password):>
Coydgoceuk6 (Coyd-goc-euk-SIX)
Caculpyep7 (Cac-ulp-yep-SEVEN)
otevDet6 (ot-ev-Det-SIX)
Jiwacwarj6 (Ji-wac-warj-SIX)
gurkOnRyet1 (gurk-On-Ryet-ONE)
EbTarIv0 (Eb-Tar-Iv-ZERO)
apgcommandsgeneratemnemonicneatpasswordsecurityutilities
Moving Files by xinu on Nov 09, 2005 07:11 PM

If you need to move files, logs, or any kind of program output off a compromised system without disrupting evidentiary data on the disk, use netcat.

On your trusted system:

$ nc -v -l -p 2222 > victim.dump

On the victim's system:

$ <program> | nc <trusted_system> 2222

Where program is the discovery application you're running (e.g. netstat -an).

cleanupcommandsforensicsncnetcatparanoidsecuritytroubleshooting
Open a Backgrounded SSH Tunnel by cygnus on May 06, 2006 12:10 AM

If you want to open an SSH tunnel in the background, use the -N and -f switches:

ssh -Nf -L2121:localhost:21 user@host
authenticationencryptionsecurityshellsshtunnel
Watching Connections by xinu on Jun 02, 2005 09:15 AM

If you want to use tcpdump to watch initiating connections (that is, the syn flag only is set indicating we're looking at the first third of the three-way handshake) on ports 80 and 443 you could do something like this:

# tcpdump '(tcp[13] & 0x3f = 2) and (dst port 80 or dst port 443)'
commandsconnectionsmonitoringnetworksecurityshelltcpdump
RSS