Menu

Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Linux Useful Commands / Features

For ease of access i want to put some of my day-to-day most useful commands in one place,
Off course share it with anyone who needs it.

Start with a quick and simple tool to verify weather a device is listening on some port/ports - NETCUT

# nc [option] [destination IP / hostname] [port]
to scan udp port use option '-zu'
to scan tcp port use option '-zt'
for list of options use just '-h'
for example :
# nc -zu google-public-dns-a.google.com 53
Output will be
Connection to google-public-dns-a.google.com. 53 port [udp/domain] succeeded!
# nc -zt google.com 80-81
Output will be
Connection to google.com 80 port [tcp/http] succeeded!
notice that non-responsive ports will not bring any output.
Create a file by size, may be useful for speed, latency or bandwidth testing
# dd if=/dev/zero of=<File Name>  bs=<Size>  count=<Multiplayer># dd if=/dev/zero of=output.dat  bs=1024  count=100240Output will be100240+0 records in100240+0 records out102645760 bytes (103 MB) copied, 0.494406 s, 208 MB/s
I'll add mode commands further on..



Hope this post was helpful, If it was please consider a donation:
BTC Address: 1CnyMpjd1RntRDxSus2hu2aDMyzL4Kj29N

LTC Address: LUqrKbzGihTU2GEnL3EwsuuLHCsxCJMdtR

SSH tunnel


The ssh tunnel can be used for several reasons, one being encripting you traffic.
To achieve this all we need is a device that allowes SSH access, i mostly use a linux pc and a putty ssh client
Putty side: notice to use a high port ( i mostly use 10000 and above) not to interrupt other traffic

now all you need is to use the tunnel as a Socks proxy,
for example in case of google chrome will look like this: chrome.exe --proxy-server="socks5://127.0.0.1:10000"

have fun :)

Hope this post was helpful, If it was please consider a donation:
BTC Address: 1CnyMpjd1RntRDxSus2hu2aDMyzL4Kj29N
LTC Address: LUqrKbzGihTU2GEnL3EwsuuLHCsxCJMdtR

IPTables for beginners

A big advantage of Linux as opposed to any windows in the field of security is the firewall in other words 'IPtables'.
In order to view the current configuration the simplest way is to issue the command  
# /etc/init.d/iptables status
This will show the rules we have configured this far with the number of each rule.


The iptables has 3 default tables (chains)
                INPUT –packets destined to the device
                OUTPUT – packets originating  from the device
                FORWARD – packets that match neither of these chains, used for NAT configuration.
Any changes are made by the following syntax # iptables –[option] [CHAIN] [action]
Most used options are: 


  • A (Add to the end of the chain)
  • D (Delete), for example to delete rule 2 -  # iptables -D OUTPUT 2
  • I (Insert) , for example to another rule before number 5 - # iptables -I INPUT 4
  • L (display) ,display rules on the inbound chain will be #i ptables –L INPUT

Inside the chain use those options to specify the rules :


  • i (match input interface)
  • o (match destination interface)
  • s (match source IP)
  • d (match destination IP) 
  • p (match protocol type)
  • m –state (match packet state)
  • m [protocol ]--dport (match destination port)
  • m [protocol ]--dport (match source port)
  • j ( action to perform on the packet)


for example let's say I wish to block NEW HTTP sessions to the device, it sould look like this :
# iptables –A INPUT  -i eth0 –p tcp –m tcp --dport 80  -m state --state NEW –j DROP
Or allow all traffic related to an existing session or on the other hand an "establish" packet type
# iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
Note that when adding a new rule, any missing information translated to "any" so in the previous example we did not need to state the source or destination seeing as we needed to match all.

When done editing make sure to save the settings in order to be loaded the next time the system boot's up, to do so issue
# Service iptables save
This should be a good starting point to practice IPtables,


Hope this post was helpful, If it was please consider a donation:
BTC Address: 1CnyMpjd1RntRDxSus2hu2aDMyzL4Kj29N

LTC Address: LUqrKbzGihTU2GEnL3EwsuuLHCsxCJMdtR

Linux RDP

Hi all,

Most of the time when I need to manage a device remotely, especially Linux based, I prefer using the CLI (SSH if possible).
But a few days ago a friend of mine suggested to use RDP, seeing as most of the offices has windows work stations using RDP instead of VNC will ease the access to a Linux server from work, and after a quick look in Google I found an application named "xrdp" witch does exactly this.
There are 2 ways installing it, first and most simple – use the 'yum install xrdp' command.
Another way is to download and compile it manually, download latest version from http://www.xrdp.org/ . 
in other words :

In my case I had to edit the file /etc/pam.d/xrdp-sesman 
And add "session sufficient /lib/security/pam_lsass.so" otherwise XVNC used 100% of my CPU.
# echo  session sufficient /lib/security/pam_lsass.so >> /etc/pam.d/xrdp-sesman

That's it

Hope this post was helpful, If it was please consider a donation:
BTC Address: 1CnyMpjd1RntRDxSus2hu2aDMyzL4Kj29N

LTC Address: LUqrKbzGihTU2GEnL3EwsuuLHCsxCJMdtR