Remove trailing space from all line of a file using powershell

We can use following script to remove space at the end of each line in a file with the help of powershell script.

$InputFile = 'C:\Users\user\Desktop\1.txt'

write-host "removing trailing space.. of file $InputFile"

$content = Get-Content $InputFile
 $content | Foreach {$_.TrimEnd()} | Set-Content newfile.txt

write-host ""
 write-host "Done!"
Posted in Other | Leave a comment

Python script to print all hyper links on a URL

We can use this script to find all hyper links on a web page. This script can be used in reconnaissance.

import urllib2
import re
import sys
#connect to a URL
url= str(sys.argv[1])
website = urllib2.urlopen(url)

#read html code
html =
print type(html)
#use re.findall to get all the links
links = re.findall('"((http|ftp)s?://.*?)"',html)
for l in links:
 print l




Posted in Python | Leave a comment


There are lot of tool to perform reconnaissance:



This command send arp request packet to a host and if a reply comes then we can say that that host is alive. This command can be useful to find out host in local LAN.

arping -c 4



nmap -n -sn

This command will try to find out if host is up or not it uses icmp echo request, echo reply, arp request , tcp syn on port 443, 80.

How to scan a single host:

nmap x.x.x.x

This command will scan a single host for tcp ports

How to scan a range of hosts:

nmap x.x.x.x-y

How to scan a subnet:

nmap x.x.x.x/24

Scan host from a file:

nmap -iL name_of_file.txt

Scan a specific port:

nmap -p 22 x.x.x.x

Scan a range of port:

nmap -p 1-100 x.x.x.x

How to find out what all cipher suites are supported by a server:

nmap -sT -PN -p 443 -n --script ssl-enum-ciphers.nse

How to scan for TCP or UDP port:

nmap -p U:53
nmap -p T:80

How to perform nmap scan without dns resolution:

nmap -n
-n option tells nmap to not to do dns resolution.

How to find out version of services:

nmap -n -sV

How to find out OS version of host:

 nmap -n -O

How to tell nmap not to do ping scan:

nmap -n -Pn -O

How to tell nmap to perform tcp 3 way handshake:

 nmap -n -sT -p 80

How to detect any firewall on target system:

nmap -p 80,443 –script=http-waf-fingerprint <site-address>
nmap -p 80,443 –script=http-waf-detect <site-address>
wafw00f <site-address>

Posted in OSCP | Leave a comment

How to resolve in Linux

While running commands with the help of sudo if you are getting following error the you have to add that user to sudo group :

is not in the sudoers file. This incident will be reported
adduser <username> sudo


Posted in Linux | Leave a comment

Understanding commands

Cut command:

 cut -d : -f1,2 /etc/passwd

delimiter is specified by -d option and in this command the delimiter is : 
-f option specifies to print 1,2 match

cd command:

cd command is used to change the directory. 

"." represents current directory 
".." represent parent directory of current directory.

if you run only cd command then you will be redirected to you home directory

if you run cd ~username then you will be redirected to home directory of that

if you run cd - then you will be kept in the previous directory 
on which you were working.

ls command:

ls command show you the current file and directories. if you want to get the hidden file then you have to run ls -a command. You can get content of multiple location in a single command.

ls  /home /bin

the above command will show the files under /home and /bin

file command:

File command tells what kind of file is.

root@ubuntu:/bin# file ping
ping: setuid ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/, for GNU/Linux 2.6.24, BuildID[sha1]=c525a765d86dbe1bdb61f56a497e6113871ef37b, stripped


All of the software will be installed in /usr directory. /usr/local will contain packages which are not pre-installed. /usr/bin contains packages which comes pre-installed.

wc command:

wc <filename>

this command is used to list the number of line , word, byte in a file. if you use wc -l you will get number of lines. if you use wc -c you will get number of byte if you use wc -w you will get number of words.

wget command:

This command is used to retrieve a webpage.

wget -k -P -r

-k : Modify the downloaded webpages so that links in those pages points to local files.
-P : put the downloaded file to mentioned path/directory
-r: follow all links on the website and get the content.


Posted in Linux | Leave a comment

Protected: Attacks

This content is password protected. To view it please enter your password below:

Posted in Other

Powershell Script to ping IPs in a file

This post explains how to ping all IP kept in a file. The following script find IP from a string and then ping to that IP.

For example if you have a string as “srx-fw-hk-03 (” it will remove all unnecessary character and find out and try to ping to

$InputFile = 'C:\Users\xyz\Desktop\list.txt'
$addresses = get-content $InputFile
write-host    ""    
write-Host "Pinging each address..."

foreach($address in $addresses)
		$regex = [regex] "\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b"
		$addr=$regex.Matches($addr) | %{ $_.value }

		if (!$addr)
		write-Host "Pinging to $addr"
		if (test-Connection $addr -Count 5 -Quiet) 
                    		write-Host "$addr responded" -ForegroundColor Green 
				Write-Warning "$addr does not respond to pings"              

write-host    ""        
write-host "Done!"
Posted in Powershell | Tagged , | Leave a comment