0% found this document useful (0 votes)
14 views38 pages

Lab Manual of Practical - II (Android + Cyber)

The document outlines practical assignments for MCA-I/SEM-II students at KDK College of Engineering, focusing on Android Programming and Cyber Forensics. It includes detailed instructions for creating various Android applications, such as a 'Hello World' app, SMS receiver, date picker, time picker, and web view implementation. Each practical includes aims, theories, steps for implementation, and sample code snippets to guide students in their projects.

Uploaded by

amityaaa1999
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views38 pages

Lab Manual of Practical - II (Android + Cyber)

The document outlines practical assignments for MCA-I/SEM-II students at KDK College of Engineering, focusing on Android Programming and Cyber Forensics. It includes detailed instructions for creating various Android applications, such as a 'Hello World' app, SMS receiver, date picker, time picker, and web view implementation. Each practical includes aims, theories, steps for implementation, and sample code snippets to guide students in their projects.

Uploaded by

amityaaa1999
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 38

KDK College of Engineering ,Nagpur

Department of Master of Computer Application


MCA-I / SEM-II ( Session : 2023-24 )
Practical – II
Subjects

Android Programming , Cyber Forensics

Sr. No. Name of Practical’s


Execute a program in Android Studio to create "Hello World" application.
1 That will display "Hello World" in the middle of the screen in the Red color
with White Screen Background.

2 Execute a program in Android Studio to Create a Simple SMS Receiver.

3 Execute a program in Android Studio to Implement date picker view.

4 Execute a program in Android Studio to Implement time picker view.

5 Execute a program in Android Studio to Implement web view.

6 Execute a program in Android Studio to Implement image switcher view.

7 Execute a program in Android Studio to Implement scroll view.

8 Execute a program in Android Studio to Implement a calling service.

9 Execute a program in Android Studio to Implement test-to-speech service.

10 Execute a program in Android Studio to Implement Camera View.

11 To study redirecting traffic tools : 1) Datapipe

12 To study redirecting traffic tools : 1) FPipe 2) WinRelay

13 To demonstrate and study Network Vulnerability Scanning tools.

14 To demonstrate and study Network Sniffers tools.


Practical – 1
Aim : To create a basic Android application that displays "Hello World" in the middle
of the screen with a red text color and a black screen background.

Theory : For creating android application that display “Hello World”, need to
follow these steps :

1. Project Setup :
• Begin by setting up a new project in Android Studio. Provide a name,
package name, and choose a target SDK version.

2. Design User Interface (UI) :


• For Designing UI we are using XML layout file named as
activity_main.xml. This file serve as blueprints for defining the visual
structure of Android applications.
• Design the user interface by editing the activity_main.xml layout file.
Add a TextView element to centre the "Hello World" text on the screen
and specify the red text color and black background color.

3. Run and Test :


• Connect an Android device or use an emulator to run the application.
Verify that the application displays "Hello World" in the middle of the screen with the
specified text color and background color.

Program :
activity_main.xml :
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000"
tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
android:textSize="32dp"
android:textColor="#ff0000"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
Output :

Result : We have successfully created the android application, that displaying the
"Hello World" text in the center of the screen with red text colour on a black
background.
Practical - 2
Aim : To create an Android application that can Receive SMS Messages in virtual
device.

Theory : In Android, SMS messages can be intercepted by registering a


BroadcastReceiver to listen for the SMS_RECEIVED_ACTION broadcast. This broadcast
is sent by the system whenever a new SMS message is received. When the broadcast
is received, the BroadcastReceiver can extract information from the SMS message, such
as the sender's phone number and the message content.

For creating an Android application that can receive SMS messages in our virtual
device, we follow these steps :

1. Set up a Virtual Device :


• Launch Android Studio and open the AVD Manager.
• Create a new virtual device or use an existing one.
• Ensure that the virtual device has SMS capabilities enabled.

2. Create a New Android Project :


• Start a new Android Studio project.
• Choose an appropriate project template and set up the project details.

3. Declare Permissions in Manifest :


• Open the AndroidManifest.xml file.
• Declare the necessary permissions.

4. Implement BroadcastReceiver :
• Create a new Java or class that extends BroadcastReceiver.
• Override the onReceive() method to handle incoming SMS messages.
• Inside the onReceive() method, extract the SMS message data and
perform any required processing.

5. Register BroadcastReceiver in Manifest :


• Register the BroadcastReceiver in the AndroidManifest.xml file.
• Define an intent filter with the action
android.provider.Telephony.SMS_RECEIVED.

6. Handle SMS Messages :


• In the onReceive() method of the BroadcastReceiver, handle the
received SMS messages.
• Extract the sender's phone number, message body, timestamp, etc.,
from the Intent object.
7. Display or Process Received Messages :
• Once we receive the SMS message data, we can display it to the user,
save it to a database, trigger an action based on its content, etc.

8. Testing :
• Deploy the application to the virtual device.
• Use the virtual device's settings to send an SMS message to the virtual
device's own number.
• Verify that the BroadcastReceiver successfully receives and processes
the incoming SMS message.

Program :
activity_main.xml :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="SMS Receiver Application"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:textSize="20dp"
android:textStyle="bold"
android:textColor="@color/blue"
/>
</RelativeLayout>

smsreceiver.java :
package com.example.smsreceive;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.telephony.SmsMessage;
import android.util.Log;

public class smsreceiver extends BroadcastReceiver {


@Override
public void onReceive(Context context, Intent intent) {
Bundle bundle = intent.getExtras();
Object[] smsobject = (Object[]) bundle.get("pdus");
for (Object obj: smsobject){
SmsMessage message =
SmsMessage.createFromPdu((byte[])obj);
String mobno = message.getDisplayOriginatingAddress();
String msg = message.getDisplayMessageBody();

Log.d("Msg Details","Mobile No"+mobno+"Msg"+msg);


}
}
}

AndroidManifest.xml :
<uses-permission android:name="android.permission.RECEIVE_SMS"/>
<uses-permission android:name="android.permission.READ_SMS"/>

Output :

Result : We have successfully created the android application, that can Receive SMS
Message in our virtual device.
Practical - 3
Aim : To create an Android Application that Implement Date Picker View in android
studio.

Theory : The Date Picker View in Android provides a user-friendly interface for
selecting dates. It allows users to navigate through months and years to pick the
desired date. It is a crucial component in applications where date selection is a
common requirement, such as in calendar apps, scheduling apps, or booking systems.

For implementing Date Picker View application in Android Studio. We follow these
steps :

1. Designing the User Interface :


• Create an XML layout file (activity_main.xml) to define the layout of the
activity.
• Add Spinners for day, month, and year selection.
• Include a Button for saving the selected date.

2. Initializing Spinners and Button :


• In the activity class (MainActivity.java), initialize the Spinners and Button.
• Initialize the Spinners with arrays of day, month, and year values.

3. Handling Save Button Click :


• Set an OnClickListener to the Save button.
• Retrieve the selected day, month, and year from the Spinners.
• Combine the selected values to create a formatted date string (day-
month-year).

4. Displaying Toast Message :


• Use the Toast class to display a popup to the user.
• Create a Toast message indicating that the date has been saved
successfully, including the selected date in the message.

5. Testing the Application :


• Run the application on an emulator or physical device.
• Interact with the Spinners to select a date.
• Click on the Save button to trigger the saving action and verify that the
Toast message appears with the selected date.

Program :
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center"
android:padding="20dp"
tools:context=".MainActivity">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Date Picker App"
android:textStyle="bold"
android:textSize="20dp"
android:textColor="@color/blue"
/>

<DatePicker
android:id="@+id/datePicker"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:calendarViewShown="false"
android:datePickerMode="spinner" />

<Button
android:id="@+id/btnSubmit"
android:text="Save"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>

</LinearLayout>

MainActivity.java

package com.example.datepickerapp;

import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

DatePicker datepicker;
Button button;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
datepicker = findViewById(R.id.datePicker);
button = findViewById(R.id.btnSubmit);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String day, month, year;
day = String.valueOf(datepicker.getDayOfMonth());
month = String.valueOf(datepicker.getMonth() + 1);
year = String.valueOf(datepicker.getYear());
Toast.makeText(MainActivity.this, day + "/" + month + "/" +
year + " Date Pick Successfully", Toast.LENGTH_SHORT).show();
}
});
}
}

Output :

Result : We have successfully implemented the Date Picker View android application in
the virtual or physical device.
Practical - 4
Aim : To create an Android Application that Implement Time Picker View in android
studio.

Theory : The Time Picker View in Android provides a user-friendly interface for
selecting time values. It allows users to adjust hours and minutes using a spinner or a
clock-style interface, depending on the version of Android. Time Picker Views are
commonly used in applications where time selection is required, such as alarm clock
apps, scheduling apps, or reminder apps.

For implementing Time Picker View application in Android Studio. We follow these
steps :

1. Set Up Project :
• Create a new Android project in Android Studio.
• Define the project details such as the package name, activity name, and
other configurations.

2. Design User Interface :


• Design the layout in activity_main.xml.
• Add a TextView to display the selected time ("Your Time Displayed
Here").
• Add a Button labelled "Pick Time".
• Add necessary layouts and views to arrange the elements aesthetically.

3. Implement Button Click Listener :


• In the activity class (MainActivity.java), initialize the Button.
• Set an OnClickListener to the Button.

4. Display Time Picker Dialog :


• In the OnClickListener, create and show a Time Picker Dialog when the
"Pick Time" button is clicked.
• Configure the Time Picker Dialog to display a clock view for selecting
hours and minutes.

5. Handle Time Selection :


• Implement the necessary logic to capture the selected time from the
Time Picker Dialog.
• Convert the selected time into a format suitable for display.

6. Update TextView with Selected Time :


• Once the time is selected, update the TextView ("Your Time Displayed
Here") with the selected time.
7. Testing :
• Run the application on an emulator or physical device.
• Click the "Pick Time" button to display the Time Picker Dialog.
• Select a time using the dialog and verify that it is displayed correctly in
the TextView.

Program :
activity_main.xml

<?xml version="1.0" encoding="utf-8"?>


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:background="#FFFFFF"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >

<TextView
android:id="@+id/timetxtview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Your Time Displays Here"
android:textSize="20sp"
android:layout_marginTop="300dp"
android:layout_centerHorizontal="true" />

<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Pick Time"
android:textSize="20sp"
android:id="@+id/picktime"
android:layout_marginTop="350sp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
/>

</RelativeLayout>

MainActivity.java

package com.example.timepickerviewapp;

import androidx.appcompat.app.AppCompatActivity;

import android.app.TimePickerDialog;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.TimePicker;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.TimeZone;

public class MainActivity extends AppCompatActivity {


private TextView TimeTextView;
private Button PickTime;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TimeTextView=findViewById(R.id.timetxtview);
PickTime=findViewById(R.id.picktime);

PickTime.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Calendar calender = Calendar.getInstance();
int hours = calender.get(Calendar.HOUR_OF_DAY);
int mins = calender.get(Calendar.MINUTE);
TimePickerDialog timePickerDialog = new
TimePickerDialog(MainActivity.this,
androidx.appcompat.R.style.Theme_AppCompat_Dialog, new
TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker view, int hourOfDay,
int minute) {
Calendar c = Calendar.getInstance();
c.set(Calendar.HOUR_OF_DAY,hourOfDay);
c.set(Calendar.MINUTE,minute);
c.setTimeZone(TimeZone.getDefault());
SimpleDateFormat format = new
SimpleDateFormat("k:mm a");
String time = format.format(c.getTime());
TimeTextView.setText(time);
}
},hours, mins, false);
timePickerDialog.show();
}
});

}
}

Output :
Result : We have successfully implemented the Time Picker View android application in
the virtual or physical device.
Practical - 5
Aim : To create a program in Android Studio to Implement web view.

Theory : The WebView component in Android enables us to embed web content,


including web pages and HTML, within their applications. Leveraging the WebKit
rendering engine, WebView seamlessly integrates online resources such as news feeds
and interactive forms, enhancing user experience by providing access to web content
without exiting the app.

For implementing Web View in Android Studio. We follow these steps :

1. Set Up Project : Create a new Android project in Android Studio with an


appropriate name and settings.

2. Design Layout : In the activity_main.xml layout file, add a WebView


component to occupy the entire screen.

3. Configure WebView : In the MainActivity.java file, initialize the WebView and


load the Amazon website URL ("https://www.amazon.com").

4. Testing and Deployment : Run the application on an emulator or physical


device to ensure that the Amazon website is displayed correctly within the
WebView. We can then distribute the app, ensuring users can access
Amazon's web content seamlessly.

5. Flexibility : To make the WebView adaptable to different websites, consider


parameterizing the website URL in the code. By doing so, we can easily switch
between different web content providers, allowing us to navigate diverse
websites without altering the app's structure.

Program :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<WebView
android:id="@+id/wv"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>

</RelativeLayout>
MainActivity.java
package com.example.webview;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.webkit.WebResourceRequest;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class MainActivity extends AppCompatActivity {
WebView webView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
webView = findViewById(R.id.wv);
webView.setWebViewClient(new WebViewClient());
webView.loadUrl("https://www.amazon.in/");
}
@Override
public void onBackPressed() {
if (webView.canGoBack()){
webView.goBack();
}else {
super.onBackPressed();
}
}
}

AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET"/>

Output :

Result : We have successfully implemented the Web View in the virtual or physical device.
Practical - 6
Aim : To create a program in Android Studio to Implement Image switcher view.

Theory : The Image Switcher view in Android enables smooth transitioning between
images, enhancing visual appeal and user engagement. It's utilized for creating image
galleries, slideshows, and applications requiring dynamic image switching, offering
smooth animation support.

For implementing Image Switcher View in Android Studio. We follow these steps :

1. Set Up Project : Create a new Android project in Android Studio.

2. Design Layout : In the activity_main.xml layout file,


• Add an ImageSwitcher in the middle of the screen to display images.
• Place "Previous" and "Next" buttons below the ImageSwitcher for
navigation.

3. Prepare Images : Add more than 4 images to the project's drawable folder.

4. Initialize Components : In the MainActivity.java file,


• Initialize the ImageSwitcher and set initial image resource.
• Set up OnClickListener for the "Previous" and "Next" buttons.

5. Handle Navigation : Implement button click listeners to switch between


images.
• When the "Previous" button is clicked, display the previous image.
• When the "Next" button is clicked, display the next image.
• Implement logic to loop back to the first image after reaching the last
image.

6. Testing and Deployment : Run the application on an emulator or physical


device.
• Verify that the ImageSwitcher displays images in the middle of the
screen.
• Test the navigation buttons to ensure smooth switching between
images.
• Confirm that the loop functionality works correctly when reaching the
end of the image list.

Program :
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="150dp"
android:textSize="30sp"
android:textColor="#000000"
android:textStyle="italic"
android:text="Image Switcher App"
/>
<ImageSwitcher
android:id="@+id/ImgSwitch"
android:layout_margin="20dp"
android:layout_width="match_parent"
android:layout_centerVertical="true"
android:layout_height="250dp"
/>

<Button
android:id="@+id/prev"
android:text="Prev"
android:layout_below="@+id/ImgSwitch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<Button
android:id="@+id/nxt"
android:text="Next"
android:layout_below="@+id/ImgSwitch"
android:layout_alignParentRight="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</RelativeLayout>

MainActivity.java
package com.example.imageswitcherview;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageSwitcher;
import android.widget.ImageView;
import android.widget.ViewSwitcher;

public class MainActivity extends AppCompatActivity {


ImageSwitcher ImgSwitch;
Button prev,nxt;

int index = 0;
int cars[]={R.drawable.a1,R.drawable.a2,R.drawable.a3,R.drawable.a4};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ImgSwitch = findViewById(R.id.ImgSwitch);
prev = findViewById(R.id.prev);
nxt = findViewById(R.id.nxt);
ImgSwitch.setFactory(new ViewSwitcher.ViewFactory() {
@Override
public View makeView() {
ImageView imageView = new
ImageView(getApplicationContext());
imageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
imageView.setMaxHeight(250);
imageView.setMaxWidth(250);
return imageView;
}
});
ImgSwitch.setImageResource(cars[index]);
prev.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
--index;
if (index<0){
index=cars.length-1;
}
ImgSwitch.setImageResource(cars[index]);
}
});
nxt.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
index++;
if(index==cars.length){
index=0;
}
ImgSwitch.setImageResource(cars[index]);
}
});
}
}
Output :

Result : We have successfully implemented the Image Switcher View in the virtual
or physical device.
Practical - 7
Aim : To create a program in Android Studio to Implement Image Scroll View.

Theory : The ScrollView in Android provides a container that enables scrolling of its
contents vertically or horizontally when the content exceeds the available screen space.
It allows users to view and interact with content that may not fit entirely on the screen.
We utilize ScrollView to accommodate large amounts of text, images, or other UI
elements within limited screen dimensions. This feature enhances usability by ensuring
that users can access all content regardless of screen size.

For implementing Image Scroll View in Android Studio. We follow these steps :

1. Set Up Project : Create a new Android project in Android Studio.

2. Prepare Images and Text : Prepare five different images and corresponding
text for each image.

3. Design Layout : In the activity_main.xml layout file,


• Add a ScrollView as the root layout.
• Inside the ScrollView, add a LinearLayout with vertical orientation to
hold the images and text.
• Add ImageView elements for each image and TextView elements for
the text below each image.

4. Set Image and Text : In the MainActivity.java file,


• Initialize ImageView and TextView elements for each image and text.
• Set the image resource and text for each ImageView and TextView
programmatically.

5. Enable Scrolling : Ensure that the ScrollView is enabled for scrolling vertically.

6. Testing and Deployment : Run the application on an emulator or physical


device.
• Verify that the ScrollView allows scrolling to view all images and text,
even if they extend beyond the screen size.

Program :
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:orientation="vertical">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >

<ImageView
android:layout_width="match_parent"
android:layout_height="160dp"
android:layout_marginHorizontal="15dp"
android:layout_marginTop="15dp"
android:src="@drawable/b1"
android:scaleType="centerCrop" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"
android:layout_marginTop="5dp"
android:text="Blue Water"
android:textSize="20dp"
android:textStyle="bold" />

<ImageView
android:layout_width="match_parent"
android:layout_height="160dp"
android:layout_marginHorizontal="15dp"
android:layout_marginTop="15dp"
android:src="@drawable/b2"
android:scaleType="centerCrop" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"
android:layout_marginTop="5dp"
android:text="Sunset"
android:textSize="20dp"
android:textStyle="bold" />

<ImageView
android:layout_width="match_parent"
android:layout_height="160dp"
android:layout_marginHorizontal="15dp"
android:layout_marginTop="15dp"
android:src="@drawable/b3"
android:scaleType="centerCrop" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"
android:layout_marginTop="5dp"
android:text="Anime Nature"
android:textSize="20dp"
android:textStyle="bold" />

<ImageView
android:layout_width="match_parent"
android:layout_height="160dp"
android:layout_marginHorizontal="15dp"
android:layout_marginTop="15dp"
android:src="@drawable/b4"
android:scaleType="centerCrop" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"
android:layout_marginTop="5dp"
android:text="Orange View"
android:textSize="20dp"
android:textStyle="bold" />

<ImageView
android:layout_width="match_parent"
android:layout_height="160dp"
android:layout_marginHorizontal="15dp"
android:layout_marginTop="15dp"
android:src="@drawable/b5"
android:scaleType="centerCrop" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"
android:layout_marginTop="5dp"
android:text="Japnese Landscape"
android:textSize="20dp"
android:textStyle="bold" />
</LinearLayout>
</ScrollView>

Output :

Result : We have successfully implemented the Image Sroll View in the virtual or physical
device.
Practical - 8
Aim : To create a program in Android Studio to Implement a calling service.

Theory : In Android, making phone calls programmatically requires permission and


intent-based implementation. We use the CALL_PHONE permission to initiate phone
calls and the Intent class to trigger the phone call action. By specifying the phone
number in the intent, the system launches the default phone dialer app, which then
initiates the call. This functionality enables users to make phone calls without leaving
the application, enhancing convenience and user experience.

For implementing Calling Service in Android Studio. We follow these steps :

1. Create a New Project : Open Android Studio and create a new project.
Choose a suitable project name and select the Empty Activity template.

2. Design the Layout : Open the activity_main.xml file from the res/layout
directory. Design the user interface (UI) for our app. We'll need a EditText for
entering the phone number and a Button for initiating the call.

3. Add Permissions : In the AndroidManifest.xml file, add the necessary


permissions for making phone calls. We'll need the CALL_PHONE permission.

<uses-permission android:name="android.permission.CALL_PHONE"/>

4. Handle Button Click : In the MainActivity.java file, write code to handle the
button click event. When the user clicks the button, we will need to retrieve
the phone number from the EditText and initiate a phone call using the Intent
class.

5. Request Permission : Since we are targeting Android 6.0 (API level 23) or
higher, we need to request the CALL_PHONE permission at runtime. Check if
the permission is granted, and if not, request it.

6. Handle Runtime Permission : Implement onRequestPermissionsResult() to


handle the result of the permission request. If the permission is granted,
proceed with making the call. If not, we can show a message to the user
indicating that the call cannot be made without the necessary permission.

7. Test : Run our app on an emulator or a real device. Enter a phone number and
click the call button to verify that the app can make calls successfully.
Program :

Activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:gravity="center"
android:padding="20dp"
android:orientation="vertical">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Calling Application"
android:textSize="30dp"
android:textStyle="bold"
android:textColor="@color/Blue"
android:layout_marginBottom="75dp"/>

<EditText
android:id="@+id/pn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter_phone_number"
android:textSize="20dp"
android:textAlignment="center"
android:inputType="phone"
/>

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/call"
android:onClick="CallToNumber"
android:layout_marginTop="90dp"
android:textStyle="bold"
android:background="@color/Blue"
/>
</LinearLayout>

MainActivity.java
package com.example.callingserviceapp;
import android.Manifest;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;

public class MainActivity extends AppCompatActivity {


EditText phoneno;
public final int REQUEST_CALL_CODE=1;
@SuppressLint("MissingInflatedId")
@Override
protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
phoneno=(EditText) findViewById(R.id.pn);
}

public void CallToNumber(View view)


{
String pn = phoneno.getText().toString();
if(ContextCompat.checkSelfPermission(MainActivity.this,
Manifest.permission.CALL_PHONE) == PackageManager.PERMISSION_GRANTED)
{
Intent intent = new Intent(Intent.ACTION_CALL);
intent.setData(Uri.parse("tel: "+pn));
startActivity(intent);
}
else {
ActivityCompat.requestPermissions(MainActivity.this, new
String[]{Manifest.permission.CALL_PHONE}, REQUEST_CALL_CODE);
}
}

public void onRequestPermissionResult(int requestCode, String[]


permissions, int[] grantResults){
super.onRequestPermissionsResult(requestCode, permissions,
grantResults);

if(grantResults.length>0 && grantResults[0] ==


PackageManager.PERMISSION_GRANTED && REQUEST_CALL_CODE==1)
{

}
else
{
ActivityCompat.requestPermissions(MainActivity.this, new
String[]{Manifest.permission.CALL_PHONE}, REQUEST_CALL_CODE);
}
}
}

Androidmanifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<uses-feature
android:name="android.hardware.telephony"
android:required="true" />
<uses-permission android:name="android.permission.CALL_PHONE"/>

<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.CallingServiceApp"
tools:targetApi="31">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER"
/>
</intent-filter>
</activity>
</application>
</manifest>

Output :

Result : We have successfully implemented the Calling Service in our physical device.
Practical - 9
Aim : To create a program in Android Studio to Implement text-to-speech service.

Theory : Android provides a built-in Text-to-Speech (TTS) engine that allows us to


convert text into speech. To implement this functionality in an Android app, we'll need
to use the TextToSpeech class provided by the Android SDK. This class provides methods
to synthesize speech from text strings and control various aspects of speech synthesis,
such as pitch, speed, and language.

For implementing Text-to-Speech Service in Android Studio. We follow these steps :

1. Create a New Project : Open Android Studio and create a new project with
an appropriate name.

2. Design the Layout : Design the user interface (UI) for our app. We'll need an
EditText for entering text input and a Button to trigger the text-to-speech
conversion. Open the activity_main.xml file from the res/layout directory and
design the layout accordingly.

3. Initialize TextToSpeech : In our MainActivity, initialize the TextToSpeech


engine in the onCreate() method. Implement the TextToSpeech.OnInitListener
interface to handle initialization callbacks.

4. Implement Text-to-Speech Conversion : Write code to convert the text


input to speech when the user clicks the Button. Use the speak() method of
the TextToSpeech class to synthesize speech from the entered text.

5. Handle Initialization : Implement the onInit() method to handle the


initialization callback. Check if the TextToSpeech engine initialized successfully
before using it.

6. Release TextToSpeech Engine : Make sure to release the TextToSpeech


engine when our app is destroyed to free up system resources. Override the
onDestroy() method to release the TextToSpeech engine.

7. Test : Run our app on physical device. Enter text input and click the Button to
verify that the app converts the text to speech successfully.

Program :
Activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<EditText
android:id="@+id/edittxt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="200dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:ems="10"
android:inputType="textMultiLine"
android:lines="5"
/>

<Button
android:id="@+id/btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Convert to Speech"
android:layout_centerHorizontal="true"
android:layout_marginTop="500dp"
android:textAlignment="center"
/>

<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Text to Speech Converter"
android:textColor="@color/blue"
android:textSize="20dp"
android:textStyle="bold"
android:layout_centerHorizontal="true"
android:layout_marginTop="200dp"

/>
</RelativeLayout>

MainActivity.java
package com.example.texttospeechserviceapp;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.speech.tts.TextToSpeech;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import java.util.Locale;

public class MainActivity extends AppCompatActivity {

TextToSpeech tts;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
EditText e1 = findViewById(R.id.edittxt);
Button b1 = findViewById(R.id.btn);
b1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
tts = new TextToSpeech(getApplicationContext(), new
TextToSpeech.OnInitListener() {
@Override
public void onInit(int i) {
if (i==TextToSpeech.SUCCESS){
tts.setLanguage(Locale.US);
tts.setSpeechRate(1.0f);

tts.speak(e1.getText().toString(),TextToSpeech.QUEUE_ADD,null);
}
}
});
}
});
}
}

Output :

Result : We have successfully implemented the Text-to-Speech Service in our


physical device.
Practical - 10
Aim : To create a program in Android Studio to Implement Camera View.

Theory : For implementing Camera View in Android Studio. We have to follow steps:

1. Create a New Project : Begin by creating a new project in Android Studio.

2. Design the Layout: Design the user interface (UI) for our app. We'll need a
layout with an ImageView to display the captured image and a Button to open
the camera and capture photos. Open the activity_main.xml layout file and
design the layout accordingly.

3. Initialize Camera : In our MainActivity, initialize Camera and set up the


camera preview use case. We'll need to create a PreviewView in our layout to
display the camera preview.

4. Open Camera and Capture Photo : Implement the functionality to open the
camera and capture photos when the user clicks the button. We'll need to use
the Camera ImageCapture use case to capture images.

5. Display Captured Photo : After capturing a photo, display it in the ImageView


in our layout. We'll need to convert the captured image to a bitmap and set it
as the image source of the ImageView.

6. Test : Run our app on an physical device. Verify that we can open the camera,
capture photos, and display them in the ImageView successfully.

Program :

Activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
tools:context=".MainActivity">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:textSize="20dp"
android:textColor="@color/blue"
android:text="Camera View App"
android:textStyle="bold" />

<ImageView
android:id="@+id/imgcamera"
android:layout_marginTop="40dp"
android:layout_width="500dp"
android:layout_height="500dp"
android:background="@color/grey"
android:scaleType="fitXY" />

<Button
android:id="@+id/btncamera"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="550dp"
android:layout_centerHorizontal="true"
android:text="Open Camera" />

</RelativeLayout>

MainActivity.java

package com.example.cameraviewapp;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.provider.MediaStore;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;

public class MainActivity extends AppCompatActivity {

private final int CAMERA_REQ_CODE = 101;


ImageView imgcamera;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

ImageView imgcamera = findViewById(R.id.imgcamera);


Button btncamera = findViewById(R.id.btncamera);

btncamera.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new
Intent(MediaStore.ACTION_IMAGE_CAPTURE_SECURE);
startActivityForResult(intent, 101, null);

}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode,
@Nullable Intent data) {

super.onActivityResult(requestCode, resultCode, data);


if (requestCode == CAMERA_REQ_CODE) {

Bitmap img = (Bitmap) data.getExtras().get("data");


imgcamera.setImageBitmap(img);
}
}
}

Output :

Result : We have successfully implemented the Camera View in our physical device.
Practical – 11

Aim : To study redirecting traffic tool : 1) Datapipe

Datapipe
A port redirection tool functions as a conduit for TCP/IP connections. For example, you could
place a datapipe on a system between a browser and a web server. If you pointed the browser
to the listening port of the system with the redirection tool, the browser would see the contents
of the web server without having to directly access the web server’s IP address. redirection tool
passes TCP/IP traffic received by the tool on one port to another port to which the tool points.
Datapipe is not exploit code. It is not a buffer overflow or a cross-site scripting attack. For all
the scenarios mentioned in these examples, command-line access is a prerequisite on the server
running the port redirection tool.
Using Datapipe is straightforward in spite of the complicated port redirection tunnels that you
can create with it:

$ ./datapipe
Usage: ./datapipe localhost localport remotehost remoteport

• The localhost argument indicates the IP address on which to open the listening port. It
may be the localhost interface (i.e., 127.0.0.1) or the address of a network interface on the local
system from which the datapipe command is being executed.
• The localport argument indicates the listening port on the local system; connections
will be made to this port number. On Unix systems, you must have root privileges to open a
listening port below 1024. If you receive an error similar to “bind: Permission denied,” your
account may not have privileges to open a reserved port.
• The remoteport argument indicates the port to which data is to be forwarded. For
example, in most cases if the target is a web server, the remoteport value will be 80.
• The remotehost argument indicates the hostname or IP address of the target.
The easiest conceptual example of port redirection is forwarding HTTP traffic. Here we set up
a datapipe to listen on a high port, 9080 in this example, that redirects to a web site of our
choice:

$ ./datapipe my.host 9080 80 www.google.com Now, we


enter this URL into a web browser: http://my.host:9080/

You should see Google’s home page. By design, Datapipe places itself in the background. So
we’ll have to use the ps and kill commands to find the process ID to stop it:
$ ps auxww | grep datapipe root 21570 0.0 0.1 44 132 ?? Is 8:45PM 0:00.00 ./datapipe
my.host 9080 80 ...
$ kill -9 21570

Result : Hence we study redirecting traffic tool Datapipe.


Practical – 12

Aim : To study redirecting traffic tools : 1) FPipe 2) WinRelay

1) FPipe
FPipe, from McAfee, implements port redirection techniques natively in Windows. It also adds
User Datagram Protocol (UDP) support, which Datapipe lacks FPipe does not require any
support DLLs or privileged user access. It runs on all Windows platforms. The lack of support
DLLs or similar files makes it easy to pick up fpipe.exe and drop it onto a system. FPipe also
adds more capability than Datapipe in its ability to use a source port and bind to a specific
interface.
Implementation
Here’s FPipe’s equivalent, with connection logs as new clients access the listening port:

C:\> fpipe -l 9080 -r 80 www.google.com Pipe


connected:
In: 10.0.1.12:57990 --> 10.0.1.5:9080
Out: 10.0.1.5:49433 --> 72.233.2.58:80
FPipe does not run as a background process. It continues to report connections until
you press ctrl-c. Notice that FPipe also indicates the peer IP addresses and the source
port number of each connection. The –s option allows FPipe to take further advantage
of port specification:

C:\> fpipe –l 139 –r 139 –s 88 192.168.97.154


This example might appear trivial at first. After all, what’s the use of redirecting one
NetBIOS port to another? The advantage is that all SMB traffic from the port redirection
has a source port of 88. This type of source port trick is useful to bypass misconfigured
firewalls. Other good source ports to try are 20, 25, 53, and 80.
The –i option comes in handy on multihomed systems, where you want to specify a
particular interface on which to listen:Whereas Datapipe’s options are few, FPipe’s
increased functionality necessitates some more command-line switches:

FPipe Option Description


-? Prints the help text.
-h
-c Maximum number of simultaneous TCP connections. The default
is 32.
Note that this has no bearing (and doesn’t make sense!) for UDP
connections.
-i The IP address of the listening interface.
-l The listening port number.
-r The remote port number (the port to which traffic is redirected).
-s The source port used for outbound traffic.
-u UDP mode.
-v Prints verbose connection information
2) WinRelay

WinRelay is another Windows-based port redirection tool. It and FPipe share the same features,
including the ability to define a static source port for redirected traffic.
Consequently, it can be used interchangeably with FPipe on any Windows platform

Usage: winrelay -lip <IP/DNS address> -lp <port> [-sip <IP/DNS address>]
[-sp <port>] -dip <IP/DNS address> -dp <port> -proto <protocol>
-lip = IP (v4/v6) or DNS address to listen at
(to listen on all addresses on all interfaces use
-lip allv4 or -lip allv6)
-lp = port to listen at
-sip = source IP (v4/v6) or DNS address for connection to destination
-sp = source port for connection to destination
-dip = destination IP (v4/v6) or DNS address
-dp = destination port
-proto = protocol ("tcp" or "udp")

Result : Hence, we study redirecting traffic tools 1) FPipe 2) WinRelay.


Practical – 13

Aim : To demonstrate and study Network Vulnerability Scanning tools.

1) Netcat
Netcat performs a narrow function with a broad application to hacking and network debugging:
it reads and writes data for TCP and UDP connections. Just like the command redirection
concepts, Netcat enables you to redirect shell commands across a network. It’s a cat command
for networking, with capabilities limited only by imagination..Netcat interacts directly with a
TCP or UDP service. You can inspect the raw data sent by a service, manually interact with the
service, or redirect network connections with stdin, stdout, or stderr.

. nc
Command Options
The basic command line for Netcat is nc [options] host ports, where host is the hostname or
IP address to connect to and ports is either a single port, a port range (specified “m-n”), or
individual ports separated by spaces, depending on the desired behavior.
Take an in-depth look at the most useful of the command-line options:
• -e command If Netcat was compiled with the GAPING_SECURITY_HOLE option,
this option causes a listening Netcat to execute command any time someone makes a
connection on the port to which it is listening, while a client Netcat will pipe the I/O to an
instance of Netcat listening elsewhere.
• -g and -G Affect loose source routing used to attempt to hide or spoof the source of
traffic.
• -i seconds Specifies the delay interval that Netcat waits between sending data.
• -l Toggles Netcat’s “listen” mode. This binds Netcat to a local port to await incoming
TCP connections, making it act as a server. For the original Netcat, the local port is specified
with the -p option (e.g., nc -l -p 8000). For modern Netcat clones, omit the -p option; they
expect to use the value from the port section of the command line (e.g., nc -l 8000). Combine
this with -u to listen for incoming UDP connections instead of TCP.
• -n Tells Netcat to forego hostname lookups. If you use this option, you must
specify an IP address instead of a hostname.
• -o file Dumps communications over this channel to the specified file. The output is
written in hexadecimal format. This option records data going in both directions and begins
each line with < or > to indicate incoming or outgoing data, respectively.
• -p port Lets you specify the local port number Netcat should use, also referred to as
the source port of a connection. For the original Netcat, this argument is required when using
the –l or –L option to start listen mode.
• -r Chooses random local and remote port numbers.
• -s Specifies the source IP address Netcat should use when making its connections.
This option allows hackers to do some pretty sneaky tricks, if it works.
• -t Enables Netcat, if compiled with the TELNET option, to handle telnet option
negotiation with a telnet server, responding with meaningless information but allowing you to
get to that login prompt you were probably looking for when using Netcat to connect to TCP
port 23.
• -u Tells Netcat to bind to a UDP port instead of a TCP port. Works for both client
and listen mode. UDP mode isn’t reliable for port scanning (most UDP services require incoming
data to elicit a response that indicates the port is open and a service is listening), but it works well
enough for simple packet communication when TCP won’t work. Some tricks for making UDP
scans more reliable are provided later in this chapter.
• -v Controls how much Netcat tells you about what it’s doing. Without –v, Netcat
only reports the data it receives. A single –v will let you know what address it’s connecting or
binding to and if any problems occur.
• -w seconds Controls how long Netcat waits before giving up on a connection. It also
tells the command how long to wait after an EOF (end-of-file) is received on standard input before
closing the connection and exiting.
• -z Tells Netcat to send only enough data to discover which ports in your specified
range actually have something listening on them. In other words, it just tries to connect, then
immediately disconnects if successful. It won’t keep the connection open. If you care only about
finding out which ports are open, you should probably be using Nmap

2) Socat

Socat is a Netcat clone with extensive configuration options. It supports several protocols, from
OpenSSL to proxies to IPv4 and IPv6. Its home page is at www.dest-unreach.org/ socat/.
The biggest difference you’ll notice from other clones is socat’s departure from familiar
command-line options. Instead of the alphabet soup of Netcat’s flags, socat uses word-based
directives on the command line. Socat is part of the BSD ports collection and available as a
package for most Linux distributions.

Implementation
Socat’s command line follows a simple format, as follows:

$ socat options address1 address2

The options resemble common “dash letter” flags such as -d, -h, and -v. These do not match the
options of other Netcat clones; they mostly work to toggle the level of debugging and type of
logging generated by socat.
The address specifications represent the most powerful, but perhaps the most confusing at first,
aspect of socat. A basic address specification consists of a keyword, followed by a list of parameters
and behavior options. Address specifications are not case sensitive, but we’ll define them in
uppercase to help distinguish them on the command line. For example, the following command
connects stdio (the first address) to TCP port 80 on a remote host (the second address):

$ socat STDIO TCP:deadliestwebattacks.com:80

Since the first address is stdio, you can pipe data into the command just as you would with nc or
any other shell command. Traffic is forwarded between the two addresses. Hence, the data piped
into stdio is forwarded to the TCP host, whose response makes the round trip back through stdio.

$ echo -n "GET / HTTP/1.1\r\nHost: deadliestwebattacks.com\r\n" | socat STDIO

Result : Hence, we study Network Vulnerability Scanning tools.


Practical – 14
Aim : To demonstrate and study Network Sniffers tools.

1) Tcpdump

The tcpdump command is present by default on most Unix-based systems. It’s long been a
part of the Unix lineage due to its usefulness in debugging networks and services. However,
its potential for abuse, especially in the era of remote administration via telnet, gave tcpdump
a bad reputation. If it’s not installed by default, check your system’s package management
software.

2) WinDump

WinDump is the tcpdump command’s counterpart for Windows systems. Its home page,
http://winpcap.org, contains installers. Note that the windump command relies on the WinPcap
driver for packet captures.

Implementation

Tcpdump and WinDump both use the packet capture (pcap) library, a set of packet capture
routines written by the Lawrence Berkeley National Laboratory. The pcap routines provide the
interface and functionality for OS-level packet filtering and disassembling IP packets into raw
data.Because WinDump is simply a Windows port of tcpdump, the two commands are mostly
interchangeable throughout this chapter. We will focus on tcpdump, noting any differences with
WinDump along the way. Most of the time, the only difference is the name of the network
interface to specify for capturing traffic.

Options and filter syntax tool can be.

-i Listens on a particular interface. With Unix, you can use ifconfig


to see the available network interfaces. With Windows, you can use windump –D or
ipconfig to find the interface number that corresponds to the network interface in which
you’re interested.
-l Has tcpdump’s standard output use line buffering so that you can page through the
output. Without this option, output redirection will keep any output from being written until
tcpdump exits.
-n Does not resolve IP addresses to hostnames.
-N Suppresses printing of the fully qualified domain name (FQDN) of the host—use
only the hostname.
-O Suppresses the packet-matching code optimizer. You can use this if it appears that
the packet filter you feed to tcpdump is missing packets or includes packets that should be
filtered out.
-p Tells tcpdump not to put the network interface in promiscuous mode.
Useful if you’re interested in sniffing only local traffic (that is, traffic to and from the
machine you’re using).
-q Tells tcpdump not to print as much packet header information. You lose
a lot of the nitty-gritty details, but you still see the timestamp and hosts involved.
-r file Tcpdump can write its output to a binary file (see -w). This tells tcpdump to
read that file and display its output. Since tcpdump captures the raw data based on the
packet filter you specify on the command line, you can use –r to reread the packet capture
data and use output-formatting command-line flags after the fact (-n, -l, -e, and -X) to
display the output in a variety of ways.
-s bytes Specifies the snapshot length (“snaplen”), in bytes per packet, tcpdump
should try to “snarf.”

Result : Hence, we study Network Sniffer Tools.

You might also like