Monday, March 7, 2016

Infinite loop on the command line using Python

Infinite loop on the command line using Python:

python -c "exec(\"import os\\nwhile True: os.system('.//prog')\")"

python -c "exec('import os\\nwhile True: os.system(\"./prog\")')"

(echo "import os" ; echo "while True: os.system('.//prog')") | python

Saturday, October 23, 2010

Install Clamav on Fedora

I decided this morning to install antivirus on my desktop running Fedora 13.
I had to do some looking around before I finally got it installed.
First
yum install clamav-scanner
yum install clamav-update

Second
cp /usr/share/doc/clamav-server-0.96.1/clamd.conf /etc/clamd.conf

Third
vim /etc/clamd.conf /etc/freshclam.conf

Follow the instructions in the file where it says:
# Comment or remove the line below.
Example

If you see errors like below refer to above.
ERROR: Please edit the example config file /etc/freshclam.conf.
ERROR: Please edit the example config file /etc/clamd.conf.
ERROR: Can't parse the config file /etc/clamd.conf

Saturday, October 16, 2010

Adding a Superuser Account to Linux

I have been testing a Linux Application and found it useful to create a second superuser account on the box besides the root account. Below are the list of commands that I used:

Check the current root account's user ID, group ID and group memberships:
    id root

Create account with superuser privileges (this is for CentOS 5.5):
    adduser -u 0 -o -g 0 -G 0,1,2,3,4,6,10 LOGIN
    passwd LOGIN

Verify change:
    id LOGIN
    less /etc/passwd
    less /etc/shadow
    less /etc/group

To change the account properties:
    usermod [options] LOGIN

To delete the account if you don't care about the home directory:
    userdel -r LOGIN

If you chose not to delete the home directory and need to go back and do it later:
    rm -rf /home/LOGIN

A better way of doing this that aligns with best practice is to create a user and assign it to the wheel group and use 'sudo' instead:
    adduser -G 10 LOGIN
    Use 'visudo' to uncomment the below line:
# %wheel ALL=(ALL) ALL

Tuesday, August 10, 2010

Testing Website Encryption

Using Openssl, use the following commands to verify website encryption strength:

openssl s_client -no_tls1 -no_ssl3 -connect :443
openssl s_client -connect :443 -cipher NULL
openssl s_client -connect :443 -cipher LOW
openssl s_client -connect :443 -cipher MEDIUM
openssl s_client -connect :443 -cipher HIGH

The only command that should not generate an error is the last. If any other command returns results instead of an error, then the site's encryption strength is not sufficient.

Tuesday, July 20, 2010

Recursively Copy Only Files to New Location

Here is a simple command to copy only the files from directories. The downside is that it does not build out the direcotry structure, but that is not what I want to do right now, I just need the files:

Copy-Item -Path C:\Tools\tes*\*.exe -Destination C:\Scripts\test\ -Recurse

Wednesday, January 13, 2010

Install or Upgrade NMAP

With root privileges, run the following command-line:

sudo wget -c "http://nmap.org/dist/nmap-5.21.tar.bz2" && bzip2 -cd nmap-5.21.tar.bz2 tar xvf - && cd nmap-5.21 && ./configure && make && sudo make install

Retrieved from http://www.h3manth.com/One%20line%20to%20install%20NMAP%205.0%20from%20source

Tuesday, December 8, 2009

WMIC Command to start and stop a service

To restart a service on a remote computer from the command line:

wmic /node:"." service where name="MpsSvc" call StopService && wmic /node:"." service where name="MpsSvc" call StartService

Friday, November 20, 2009

Nice Information Security Quote

National Security Agency (NSA) information assurance director Richard Schaeffer said that agencies can protect their systems against 80 percent of known cyber attacks by following three steps:

  1. implementing best security practices
  2. configuring networks properly
  3. monitoring networks effectively

My bet is that people and processes fill the gap.

Wednesday, November 18, 2009

NMAP

Here is an interesting NMAP example to run against a box.

nmap.exe -v -sS -P0 -p1- --script all --script-args=smbuser=USERNAME,smbpass=PASSWORD,smbdomain=DOMAIN computer.domain

Monday, November 16, 2009

MySQL Backup

Ever had to backup a MySQL database running on Windows. Well this was my first time. I have a pretty active database that grows to about 70GB over the course of a month. I wanted to perform the backup using a MySQL tool. I suppose I could have just run a Windows backup, but that wouldn't be much fun. So here is what I ended up doing. I ran the below command from within the folder I wanted to land the dump files in. For instance I wanted my dump files to reside in C:\mysql\backup so I ran the below command from within this folder I created.

..\bin\mysqldump.exe --user=root --password=abc123! --routines --create-options --single-transaction --skip-add-locks --skip-lock-tables --default-character-set=utf8 database table bzip2.exe > database_table.sql.bz2

To get the compression running, I downloaded Cygwin to use the bzip2.exe utility. I actually needed the below files for the bzip2.exe utility to run and I placed these files in the newly created backup folder:
cygiconv-2.dll
cygintl-8.dll
cygwin1.dll
bzip2.exe

To decompress the file simply run: bzip2.exe -d database_table.sql.bz2.

I apologize, but I can't list all the sites I looked at to come up with this specific command but it is not original. Maybe the original part is running on Windows instead of *nix. Maybe next time I will just run Windows backup

Monday, November 9, 2009

Alabama, Atlanta Bound!

Since I am an Alabama fan and this is my blog, I just want to say Roll Tide!

Upgrade Nessus

Ever wonder how to upgrade Nessus installed on a Ubuntu box. Since I am a Windows admin and not a Linux, I just spent 15 mintues trying to find the command. So next time I have it:

dpkg -i Nessus-4.0.2-ubuntu810_amd64.deb

simple huh!

Friday, October 30, 2009

Using PuTTY Secure Copy client

Here are a few simple examples for using the PSCP command line utility for moving files between Windows and *nix over SSH. I realize it is much more capable but these are really the only reasons I use it.

Copy from *nix:
pscp.exe -2 -scp username@server.domain.loc:/home/username/*.* c:\Temp\

Copy to *nix:
pscp.exe -2 -scp c:\Temp\*.* username@server.domain.loc:/home/username/

List files and directories on *nix:
pscp.exe -2 -scp -ls username@server.domain.loc:/home/username/

If you are familiar with FTP, you can use the PSFTP.EXE tool to do the same thing as in the below example:

psftp.exe -2 -l username server.domain.loc

Once authenticated use the mget command to copy files to the local Windows computer.

Thursday, October 22, 2009

Upgrade ePO Agent


  1. Uninstall Agent (this step may be unnecessary since using /FORCEINSTALL to install a new agent removes the current agent but it doesn't hurt and may prevent install failures.)


    1. Use the /REMOVE command-line option to uninstall the agent.

    2. Click Start and the Run.

    3. Click Browse and navigate to the following file: "C:\Program Files\Network Associates\Common Framework\FrmInst.exe"

    4. Append /REMOVE=AGENT to the end of the file path in the "Open:" box and click OK.

    5. The McAfee Agent and Updater Installation window may appear. Click OK upon completion.


  2. Install New Agent: FramePkg.exe /FORCEINSTALL /INSTALL=AGENT /INSTDIR="%ProgramFiles%\McAfee\Common Framework"

  3. Test Connectivity: "%ProgramFiles%\MCAFEE\COMMON FRAMEWORK\CMDAGENT.EXE" /C /E /P /S

  4. Try to manually update from new ePO server