Beruflich Dokumente
Kultur Dokumente
6 Using NMap
7 Socket Programming
Step 8: Here, it will display the site (/~csci571/missingfile.html) automatically through the
network.
HTTP.REQUEST.FULL_URI
Step 16: Now go to wireshark and see the packets and filter it as http.
Step 1: Open Linux Server in VMware Workstation. Open the terminal (Applications ->
Accessories -> Terminal). Enter the command ‘sudoiptables -F’ to flush all existing chains
and then enter, ‘sudoiptables -L’ after every command to view the rules if they have been
applied.
SSH:
Step 2: Enter the command ‘sudoiptables -A INPUT -p tcp --dportssh -j ACCEPT’ to allow
the incoming traffic at the destination port,.i.e, SSH(22).
DROP:
Step 3: Enter the command ‘sudoiptables -A INPUT -j DROP’ to drop all input traffic.
INSERT:
Step 4: Enter the command ‘sudoiptables -I INPUT 1 -m conntrack --ctstate RELATED,
ESTABLISHED -j ACCEPT’. After executing this command, the connection is established,
and a connection is added at the first row.
LOOPBACK INTERFACE:
Step 6: Enter the command ‘sudoiptables -I INPUT 1 -i lo -j ACCEPT’. After executing this
command, an interface is inserted at the first row.
LOGGING CHAIN
Step 8: Enter the command ‘sudoiptables -N LOGGING’ to create a new chain called
‘LOGGING’ whose name is predefined.
Fill in the required details. The certificates can only be installed in the browser, where the
registration was done from
Outlook Configuration
Go to http://www.google.com/settings -> Security Tab
In Gmail, go to Settings -> Forwarding / POP IMAP and Enable POP and
Enable IMAP
To export the public key, go into Internet Options, Certificates and export the certificate
w/out private key
Step 1: Start Ubuntu from ‘Oracle VM VirtualBox Manager’ and login as a “Guest User”.
Step2: Open the terminal using ‘Ctrl+Alt+T’. Type this ‘gedit’ command in terminal for
opening the text editor.
Code:
#include <stdio.h>
#include <string.h>
int main(void)
{
char buff[15];
int pass = 0;
printf("\n Enter the password : \n");
gets(buff);
if(strcmp(buff, "@@@patkar@@@"))
{
printf ("\n Wrong Password \n");
}
else
{
printf ("\n Correct Password \n");
pass = 1;
}
if(pass)
{
/* Now Give root or admin rights to user*/
printf ("\n Root privileges given to the user \n");
}
return 0;
}
Step 4: Open the terminal using ‘Ctrl+Alt+T’. Enter the command ‘cd Desktop’ and then
‘gccbufferoverflow.c –o bufferoverflow’ where bufferoverflow.c denotes the file containing
the code and bufferoverflow is the name of the output file to be created.
The warnings are displayed on executing the above command. Type the command
‘./bufferoverflow’ to execute the program.
Step 7: On entering the password of size more than 14, the output is displayed as ‘Core
dumped’ because the size specified in the program is 15, i.e., 0 to 14. If the password entered
is 15 characters, then only ‘Wrong Password’ is displayed because gets() has a feature of
allowing in one more size than the specified size, i.e. it allows character at 15th position
although size specified is till 14.
Step 1: Start Ubuntu from ‘Oracle VM VirtualBox Manager’ and login as a “Guest User”.
CODE:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
Step 8: When no input is provided, then buffer size is displayed as 0. When the input
provided is only hello mscit, then the buffer size is displayed as 11. When the input provided
is hello %x %x, then the buffer size is displayed as 10. The inputs hello and the format
strings parameters will be attributed to the variable buf inside the code which should take the
place of the %s in the Data input. So now the printf argument looks like: printf(“Buffer size
is: (%d) \n Data input: Bob %x %x \n” , strlen (buf) , buf ) ;When the application prints the
results, the format function will interpret the format string inputs, showing the content of a
memory address.
Step 1: Open Nmapzenmap GUI Enter Target IP addressselect Intense scan click on
scan.Nmap Output tab will display all info about ip address.
Step 7: Enter the second ip address here we enter the Google sites ip address
GreetingClient.Java
import java.net.*;
import java.io.*;
import java.net.*;
import java.io.*;
public class GreetingServer extends Thread
{
private ServerSocket serverSocket;
public GreetingServer(int port) throws IOException
{
serverSocket = new ServerSocket(port); serverSocket.setSoTimeout(10000);
}
public void run()
{
while(true)
{
try
{
System.out.println("Waiting for client on port " + serverSocket.getLocalPort() + "...");
Socket server = serverSocket.accept(); System.out.println("Just connected to "+
server.getRemoteSocketAddress());
DataInputStream in = new DataInputStream(server.getInputStream());
System.out.println(in.readUTF()); DataOutputStream out = new
DataOutputStream(server.getOutputStream());
out.writeUTF("Thank you for connecting to " + server.getLocalSocketAddress() +
"\nGoodbye!"); server.close();
}
catch(SocketTimeoutException s)
{
System.out.println("Socket timed out!"); break;
}
catch(IOException e)
{
e.printStackTrace();
break;
}
}
}
TCPServer.java
import java.io.*;
import java.net.*;
class TCPServer
{
public static void main(String argv[]) throws Exception
{
String clientSentence;
String capitalizedSentence;
ServerSocket welcomeSocket = new ServerSocket(6789); while(true)
{
Socket connectionSocket = welcomeSocket.accept(); BufferedReader inFromClient = new
BufferedReader(new InputStreamReader(connectionSocket.getInputStream()));
DataOutputStream outToClient = new
DataOutputStream(connectionSocket.getOutputStream()); clientSentence =
inFromClient.readLine(); System.out.println("Received: " + clientSentence);
capitalizedSentence = clientSentence.toUpperCase() + '\n';
outToClient.writeBytes(capitalizedSentence);
}
}
}
import java.io.*;
import java.net.*;
class TCPClient
{
public static void main(String argv[]) throws Exception
{
String sentence;
String modifiedSentence;
BufferedReader inFromUser = new BufferedReader(new InputStreamReader(System.in));
Socket clientSocket = new Socket("localhost", 6789);
DataOutputStream outToServer = new DataOutputStream(clientSocket.getOutputStream());
BufferedReader inFromServer = new BufferedReader(new
InputStreamReader(clientSocket.getInputStream()));
sentence = inFromUser.readLine(); outToServer.writeBytes(sentence + '\n');
modifiedSentence = inFromServer.readLine(); System.out.println("FROM SERVER: " +
modifiedSentence); clientSocket.close();
}
}