Showing posts with label hack. Show all posts
Showing posts with label hack. Show all posts

Friday, 2 December 2016

Password less authentication in linux

Source : host A
Destination: host B


1. Run the below command for generating public and private key( host A)

ssh-keygen -t rsa

/home/username/id_rsa (private key)
/home/username/id_rsa.pub (public key)

2. ssh-copy-id -i  /home/username/id_rsa.pub host_B_ip_address



Alternate way:

* Copy the text inside id_rsa.pub file .

* Login into host B and go to /root/username/

and create new file "authorized_keys" and paste text copied from step 2.

*  Login into Host A to Host B password less.(ssh host B)


Simple:

Put public key(host A) to authorized_keys(host B)

Now Host A can login into host B without any password.



Wednesday, 21 September 2016

Linux user management commands

Create user in linux :

root@test2:~# useradd test1
root@test2:~# passwd test1
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

Note : we can also create user with adduser command.

-Whenever user is created in linux the default access is assigned to user via /etc/profile file.
-Username is added to /etc/passwd file.
-Same as username one group is created in /etc/group file.
-Encrypted password save into /etc/shadow file.


Delete user in linux:

root@test2:~# userdel test1


Lock user account in linux:

root@test2:~# passwd -l test1
passwd: password expiry information changed.

when user will try to login he will get below message.

login as: test1
test1@192.168.0.10's password:
Access denied

When the user account is locked we can see ! sign after username in /etc/shadow file.

root@test2:~# cat /etc/shadow | grep test
test1:!$6$prWdpshs$A0WNBzbHC5sEke7hatNq8lFaB/Ux.SQ3vRc1.If4joDTD/AMpsuPYT.1mCmfBDUCoh6ND7izfcT9buo1wiZ581:17066:0:99999:7:::


Unlock user account in linux:

root@test2:~# passwd -u test1

passwd: password expiry information changed.

You can also unlock by editing /etc/sadow file. remove the ! sign from locked account.


Linux user account details :

root@test2:~# chage -l test1
Last password change                                    : Sep 22, 2016
Password expires                                        : never
Password inactive                                       : never
Account expires                                         : never
Minimum number of days between password change          : 0
Maximum number of days between password change          : 99999
Number of days of warning before password expires       : 7

See process run by user :

root@test2:~# ps  -u test1
  PID TTY          TIME CMD
 2442 ?        00:00:00 systemd
 2443 ?        00:00:00 (sd-pam)
 2463 ?        00:00:00 sshd
 2464 pts/0    00:00:00 sh

Root access to test1 user :

Edit the /etc/sudoers and add the below line.

%test1  ALL=(ALL:ALL) ALL

Switch to another user :

sudo su - username

root@test2:~# sudo su - test1
No directory, logging in with HOME=/
$ bash
test1@test2:/$




Monday, 1 August 2016

Iptables linux firewall simple command

What is Iptables ?

Iptables is a rule based firewall and it is pre-installed on Linux operating system which control the incoming and outgoing traffic. We can create chain rule and block black listed IP.

For example:

Block IP:

If we got DDOS attack on web server from 192.168.1.10 now we can block the inbound traffic from this IP using Iptabes.

iptables -D INPUT -s 192.168.1.10 -j DROP

or range of IP

iptables -A INPUT -s 192.168.0.0/24 -j DROP

Now from 192.168.1.10 will not able to access anything on your server.

Restricting access with mac address :

iptables -A INPUT -m mac --mac-source 0E:0F:EA:91:04:08 -j DROP

iptables -A INPUT -m mac --mac-source 0E:0F:EA:91:04:08 -j ACCEPT


Restricting access on port:

iptables -A INPUT -s 192.168.1.0/24 -m state --state NEW -p tcp --dport 22 -j ACCEPT

iptables -A INPUT -s 192.168.1.0/24 -m state --state NEW -p tcp --dport 25-j ACCEPT

Port 22(SSH) and 25(SMTP)  is accessible only from 192.168.1.0/24

List of rule :

iptables -L -n -v

-L : List rules.
-v : Display detailed information. 
-n : Display IP address and port in numeric format.

Deleting rule :

iptables -D INPUT -s 192.168.0.10 -j DROP

iptables -D INPUT -m mac --mac-source 0E:0F:EA:91:04:08 -j DROP

iptables -D INPUT -s 192.168.1.0/24 -m state --state NEW -p tcp --dport 22 -j ACCEPT







Monday, 4 July 2016

Run sudo command with php or Apache in linux

Ubuntu run apache as the www-data user and sudo command ask for password everytime you run sudo command. If you want to use sudo without a password from a web page, you need to allow www-data user to run sudo command with no password.

Steps:

1. Run  sudo visudo  command.

2. add below lines at the end of the file.

www-data ALL=NOPASSWD: ALL

3. or you can specify only for specific program.

www-data ALL=NOPASSWD: /sbin/iptables


Below PHP code to ban ip using ufw firewall in Linux ubuntu.


 <form action="" method="post">  
 Enter IP : <input type="text" name="ip">  
 <input type="submit" value="Ban IP">  
 </form>  
   
 <?php  
   
 if(isset($_POST["ip"]))  
 {  
 $ip= $_POST["ip"];  
 echo "$ip";  
 $ban = shell_exec("sudo ufw deny from $ip");  
 echo "Banned".$ban;  
 }  
   
 ?>

4. Done 

Thursday, 23 June 2016

Types of Hackers

There are different types of hackers some do for money some do for fun.

White hat :

A white hat hacker breaks security for non-malicious reasons, either to test their own security system, perform penetration tests or vulnerability assessments for a client - or while working for a security company which makes security software. The term is generally synonymous with ethical hacker, and the EC-Council,[17] among others, have developed certifications, courseware, classes, and online training covering the diverse arena of ethical hacking.
White hat hackers are usually seen as hackers who use their skills to benefit society. They may be reformed black hat hackers or they may simply be well-versed in the methods and techniques used by hackers. An organization can hire these consultants to do tests and implement best practices that make them less vulnerable to malicious hacking attempts in the future.

Black hat :

A "black hat" hacker is a hacker who "violates computer security for little reason beyond maliciousness or for personal gain" (Moore, 2005). The term was coined by Richard Stallman, to contrast the maliciousness of a criminal hacker versus the spirit of playfulness and exploration of hacker culture, or the ethos of the white hat hacker who performs hacking duties to identify places to repair.[19] Black hat hackers form the stereotypical, illegal hacking groups often portrayed in popular culture, and are "the epitome of all that the public fears in a computer criminal".
A black hat hacker is an individual with extensive computer knowledge whose purpose is to breach or bypass internet security. Black hat hackers are also known as crackers or dark-side hackers. The general view is that, while hackers build things, crackers break things. They are computer security hackers that break into computers and networks or also create computer viruses. The term “black hat” comes from old westerns where the bad guys usually wore black hats and the good guys wore white ones.

Grey hat :

A grey hat hacker lies between a black hat and a white hat hacker. A grey hat hacker may surf the Internet and hack into a computer system for the sole purpose of notifying the administrator that their system has a security defect, for example. They may then offer to correct the defect for a fee.[20] Grey hat hackers sometimes find the defect of a system and publish the facts to the world instead of a group of people. Even though grey hat hackers may not necessarily perform hacking for their personal gain, unauthorized access to a system can be considered illegal and unethical.

Elite hacker :

A social status among hackers, elite is used to describe the most skilled. Newly discovered exploits circulate among these hackers. Elite groups such as Masters of Deceptionconferred a kind of credibility on their members.

Script kiddie :

A script kiddie (also known as a skid or skiddie) is an unskilled hacker who breaks into computer systems by using automated tools written by others (usually by other black hat hackers), hence the term script  kiddie usually with little understanding of the underlying concept.

Neophyte(hacking start here) :

A neophyte ("newbie", or "noob") is someone who is new to hacking or phreaking and has almost no knowledge or experience of the workings of technology and hacking.

Blue hat :

A blue hat hacker is someone outside computer security consulting firms who is used to bug-test a system prior to its launch, looking for exploits so they can be closed. Microsoftalso uses the term BlueHat to represent a series of security briefing events.

Hacktivist :

A hacktivist is a hacker who utilizes technology to publicize a social, ideological, religious or political message.
Hacktivism can be divided into two main groups:

Nation state :

Intelligence agencies and cyberwarfare operatives of nation states.

Organized criminal gangs :

Groups of hackers that carry out organized criminal activities for profit.

Monday, 1 February 2016

How to change pc mac address

What is MAC address?

MAC(media access control address) is physical address of your computer system. Each device have unique MAC address. MAC address is assigned by manufacture into NIC(network interface controller)

Why to change MAC address?

1. Motherboard, router is changed and your ISP is using the previous MAC address.
2. If MAC address is blocked by the firewall or router
3. Safety

Watch Video : https://www.youtube.com/watch?v=2HwVB2XlQfk(audio+video  mixing with ffmpeg)
ffmpeg.exe -ss 00:00:00  -t 116 -i "mac2.avi" -ss 0:00:00 -t 116 -i "mac2.mp3" -map 0:v:0 -map 1:a:0 -y out.mp4

More about ffmpeg :http://hackfi.blogspot.in/2015/10/slow-motion-video-using-ffmpeg.html

How to change MAC address in windows:

1. Generate random MAC address.

2. Go to Control panel >> Network and Internet >> Network connection.




3. Right Click on Local Area Connection >> Configure.



4. Advanced >> select Network Address >> enter "MAC address" into value>> Ok

5. To check MAC address "ipconfig -all"







Sunday, 10 January 2016

Schedule,abort,reboot,shutdown in windows with cmd

Sometime after the software update windows automatically restart the system.(system will restart in 10 minutes) Or you may want to schedule shutdown or reboot of system.


To abort this shutdown: (before you know how to shutdown you should know how to abort)

shutdown -a or shutdown /a

Scheduling shutdown, reboot time for windows:

shutdown -s -t 30  (Shutdown will be in 30 sec)

shutdown -r -t 30 (Reboot will be in 30 sec)



Create batch file off above command:

shutdown.bat ( open notepad and write below save as shudown.bat file)

shutdown.exe -s -t -60

abort.bat ( open notepad and write below save as abort.bat file)

shutdown.exe -a

HackTips with shutdown.bat file:(first read solution)

If the shutdown.bat file is copied to "startup" folder of windows then whenever the system will start
the shutdown.bat file  command will run and system will shutdown. This will create shutdown loop the system will never start.

Where is startup folder(startup folder path)

Solution: 

Need to start windows in safe mode by pressing F8 key from your keyboard and we need to delete the shutdown.bat file from the startup folder.(in safe mode only basic programs are loaded)

Fun stuff:

Create shutdown.bat(with -t 00) file and send your friend and tell them to double click on that file to see magic or whatever.

Schedule shutdown time in some system.


Wednesday, 7 October 2015

How to see password in password textbox

How to see password in password Textbox

When we type password in any password box it's get encrypted and you will see only ****.
 It is very easy just change the text Input type from password to text.

1. Right click on password text box and go to Inspect element.


2. At below(sometimes right) you will see Inspect tab. <input> Search for type="passoword" .



3. Change input type from type="passoword" to type="text" ..


4. Press Enter key.