Tag Archives: unix

nmap scans ips and ports

A useful linux/unix tool, nmap scans ips and ports of given hosts: Nmap 5.21 ( http://nmap.org ) Usage: nmap [Scan Type(s)] [Options] {target specification} TARGET SPECIFICATION: Can pass hostnames, IP addresses, networks, etc. Ex: scanme.nmap.org, 192.168.0.1; 10.0.0-255.1-254 -iL <inputfilename>: Input from list of hosts/networks -iR <num hosts>: Choose random targets –exclude <host1 [,host2][,host3],…>: Exclude hosts/networks –excludefile <exclude_file>: Exclude list from file HOST DISCOVERY: -sL: List Scan – simply list targets to scan -sP: Ping Scan – go no further than determining if host is online -PN: Treat all hosts as online — skip host discovery -PS/PA/PU/PY[portlist]: TCP SYN/ACK, UDP or SCTP discovery to given ports -PE/PP/PM: ICMP echo, timestamp, and netmask request discovery probes -PO[protocol list]: IP Protocol Ping -n/-R: Never do DNS resolution/Always resolve [default: sometimes] –dns-servers <serv1 [,serv2],…>: Specify custom DNS servers –system-dns: Use OS’s DNS resolver –traceroute: Trace hop path to each host SCAN TECHNIQUES: -sS/sT/sA/sW/sM: TCP SYN/Connect()/ACK/Window/Maimon scans -sU: UDP Scan -sN/sF/sX: TCP Null, FIN, and Xmas scans –scanflags <flags>: Customize TCP scan flags -sI <zombie host[:probeport]>: Idle scan -sY/sZ: SCTP INIT/COOKIE-ECHO scans -sO: IP protocol scan -b <ftp relay host>: FTP bounce scan PORT SPECIFICATION AND SCAN ORDER: -p <port ranges>: Only scan specified ports Ex: -p22; -p1-65535; -p U:53,111,137,T:21-25,80,139,8080 -F: Fast mode – Scan fewer ports than the default scan -r: Scan ports consecutively – don’t randomize –top-ports <number>: Scan </number><number> most common ports –port-ratio <ratio>: Scan ports more common than </ratio><ratio> SERVICE/VERSION DETECTION: -sV: Probe open ports to determine service/version info –version-intensity <level>: … Continue reading

Posted in Security, Server Admin, Tech Tips | Tagged , , , | Leave a comment

Elinks User Agent Override

To manually set the useragent for the e-links web browser, edit this file: ~/.elinks/elinks.conf The syntax for setting or overriding the user agent is something like this: set protocol.http.user_agent = “Firefox/2.0.0.4” Or possibly this for a more realistic agent string: set protocol.http.user_agent = “Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.4) Gecko/20060426 Firefox/1.5.0.4”

Posted in Web Development | Tagged , , , , , , , | Leave a comment

Unix: Change To Last Directory

If you’re wondering, can I: in unix, change to last directory in unix, cd to last used directory in unix change to most recent directory Well, cd – will switch you to the previous directory. For example, if you are in /usr/bin/tmp, and go to /etc, you can type cd – to go back to /usr/bin/tmp. You can use this to toggle back and forth between two directories. cd dir (without a /) will put you in a subdirectory. for example, if you are in /usr, typing cd bin will put you in /usr/bin, while cd /bin puts you in /bin. cd .. will move you up one directory. So, if you are /usr/bin/tmp, cd .. moves you to /usr/bin, while cd ../.. moves you to /usr (i.e. up two levels). You can use this indirection to access subdirectories too. So, from /usr/bin/tmp, you can use cd ../../local to go to /usr/local. cd by itself or cd ~ will always put you in your home directory. cd ~username will put you in username’s home directory.

Posted in Tech Tips | Tagged , | Leave a comment

Where Linux Mail files are stored on OS X

“1 new message” – a common notification when you start the terminal, especially if you have cron jobs set up and an error occurs. You can use the built-in “mail” function to check and erase messages, or you can manually edit / delete the files located in the directory: /var/mail

Posted in Tech Tips | Tagged , , , , | Leave a comment

Replacing Variables with Bash

$(var:pos[:len]) # extract substr from pos (0-based) for len $(var/substr/repl) # replace first match $(var//substr/repl) # replace all matches $(var/#substr/repl) # replace if matches at beginning (non-greedy) $(var/##substr/repl) # replace if matches at beginning (greedy) $(var/%substr/repl) # replace if matches at end (non-greedy) $(var/%%substr/repl) # replace if matches at end (greedy) ${#var} # returns length of $var ${!var} # indirect expansion

Posted in Web Development | Tagged , | Leave a comment

unix commands

find / grep find . -iname “*.php” -exec grep -textString {} \;

Posted in Tech Tips | Tagged , , | Leave a comment

ibm aix

Maybe this still has a place in today’s tech world, but I think IBM should just give up and move over to working with true *NIX clipped from en.wikipedia.org IBM AIX AIX (Advanced Interactive eXecutive) is the name given to a series of proprietary operating systems sold by IBM for several of its computer system platforms, based on UNIX System V with 4.3BSD-compatible command and programming interface extensions. Latest stable release 6.1 / November, 2007 Source model Closed source License Proprietary  

Posted in Tech Opinion | Tagged | Leave a comment

Useful Unix Commands

To backup everything in the current directory, exclude anything ending with jpg: tar cvf mybackup.tar –exclude “*.jpg” . To exclude more than one type, just add another –exclude statement: tar cvf mybackup.tar –exclude “.jpg” –exclude “.gif” . Search current directory and sub directories for mp3 files: find . -name *mp3 Need to Learn: how to get the total size of the files returned by the above search command AIX Those were on RHEL, not aix – they will work for a lamp instance. ¬†With AIX we have to consult the man tar page. This should work: find . ! -name “*.mp3” > inputfilelist tar -cvf mybackup.tar -L inputfilelist This should also work (in the opposite direction): find . -name “*.mp3” > excludefilelist tar -cvf mybackup.tar -X excludefilelist . In either case, you can use this to see if there are any mp3 files in the archive: tar -tvf mybackup.tar | grep mp3

Posted in Tech Opinion, Tech Tips, Web Development | Tagged | Leave a comment