zapatista tribal port scan code+
A port scan is not a crime. It is no different in spirit from counting
the windows of a building on a public sidewalk, or observing the number
of doors.
– EDT, 2001
+ + +
Chiapas, Mexico - January 3rd, 2000 - the Zapatista Air Force
"bombarded" the federal barracks of the Mexican Army with hundreds of
paper airplanes. Each one carrying a message to counter the deafening
noise created by the soldiers attempts to silence their protests.
–EZLN
http://www.ezln.org
+ + +
In remembrance of this event the Electronic Disturbance Theater (EDT)
releases a digital translation of the Zapatista Air Force Action:
the 'zapatista tribal port scan code.'
The distribution of the source code for the ++ zapatista tribal port scan
(ZTPS)++
will be followed by the release of a ZTPS Tool Kit on January 15th, 2001
through EDT's home page.
Electronic Disturbance Theater
http://www.thing.net/~rdom/ecd/ecd.html
++ zapatista tribal port scan (ZTPS) by EDT++
/*
socketChecker -a simple port scanning class- Opens a socket, checks
it for a service, with a time-out. Returns a String describing either
the socket response, or the result of the attempt to open the socket.
Works for both tcp-ip and udp services. A call to the factory method
checkSocket does it all (see below). Since the method returns a String
object after "time-out" milliseconds, you might want to put the call
*the checkSocket* method in it's own thread.
*This code is completely free source
*If you download or use this code, please feel compelled to make any
improvements that you might make available to the public domain.
*Utilize this code at your own risk - port scanning will sometimes
bristle the hairs of some sys admins. As we know, the only thing a sys
admin needs to do is to complain (regardless of truth, and without
responsible investigation), for an Internet Service Provider (ISP) to
pull the plug on a user. *But if a socket is visible over the *public*
Internet, then a sys admin, (and everyone else), should expect it to be
scanned. A port scan is not a crime. It is no different in spirit from
counting the windows of a building on a public sidewalk, or observing
the number of doors. If it sets off alarms, then it is the
responsibility of the sys admin to separate the potential threats from
poetry, free vision, or paper airplanes in public places. Electronic
Disturbance Theater
*/
import java.net.*;
import java.io.*;
public class socketChecker implements Runnable{
file://declarations
private String server;
private DatagramSocket dsock;
private DatagramPacket packet;
private int port;
private Socket socket;
private String response="";
private BufferedReader is;
private PrintWriter os;
public static final int TCP=0;
public static final int UDP=1;
private int type;
private boolean tcp; // if tcp true, then a tcp scan is done. if false,
udp.
private String message;
private boolean error=false;
// constructor - this is used by the factory method. You should not call
it.
public socketChecker(String server, int port, int type, String message)
{ socket=null; dsock=null;
packet=null;
this.server=server;
this.port=port;
this.type=type;
this.message=message;
response="trying; no connection"; // default response reports message
// if there is a problem connecting it will be caught as
// an exception in the run method…
}
// methods
/* This static factory method is what you use to scan a port
public static String checkSocket(String ahost, int aport,
int timeout, int type, String message);
ahost - the machine to scan
aport - the port to scan
timeout - tells the thread how many milliseconds to wait for the socket
to respond…
int type - you can use the static ints socketChecker.TCP or
socketChecker.UDP to choose tcp or udp scans…
message - a String used either to message a port (TCP), or as
the data for the UDP packet.
(use depends upon "type" of scan selected in type)
*/
public static String checkSocket(String ahost, int aport,
int timeout, int type, String message) {
socketChecker look= new socketChecker(ahost, aport, type, message);
Thread t = new Thread(look);
t.start();
try {
t.join(timeout);
} catch (InterruptedException e) {
System.out.println("InterruptedException e: " + e.toString());
}
return look.getResponse();
}
// getResponse simply returns the String response
private String getResponse() {
return response;
}
// the run method
public void run() {
if (type==TCP) {
tcp=true;
} else {
tcp=false;
}
if (tcp) {
response="trying TCP="" + message + ""; no connection";
// open a tcp socket
try {
socket = new Socket(server, port);
} catch (Exception e) { // catches mainly security and unknown host
exceptions
response+="; " + e.toString();
error=true;
}
if (!error) { // if the socket is open Reader and Writer
try {
is= new BufferedReader(
new InputStreamReader(socket.getInputStream())
);
os= new PrintWriter(
socket.getOutputStream(),true /* autoFlush */
);
} catch (IOException e) {
response+="; IO problem; " + e.toString();
error=true;
}
if (!error) { // if Reader and Writer are open
response="sending TCP="" + message + ""; no reply";
try {
os.println(message);
} catch (Exception e) {
response+=("; "+e.toString()+"="+message);
}
try {
response="sending TCP="" + message + ""; reply="+is.readLine();
} catch (IOException e) {
response+="; " + e.toString();
}
}
}
} else {
// open a udp socket, send a packet, get response..
response="trying UDP packet="" + message + ""; can't create";
try {
dsock=new DatagramSocket();
} catch (SocketException se) {
response="SocketException: " + se.toString();
error=true;
} catch (Exception e) { // mostly to gather the variety of possible
security exceptions
response+="; " + e.toString();
error=true;
}
if (!error) {
response="sending UDP packet="" + message + ""; can't send";
try {
dsock.send(new DatagramPacket(message.getBytes(),
message.getBytes().length,
InetAddress.getByName(server),
port)
);
} catch (UnknownHostException e) {
response+="UnknownHostException:" + e.toString();
error=true;
} catch (IOException e) {
response+="IOException: " + e.toString();
error=true;
} catch (Exception e) { // mostly to gather the variety of possible
security exceptions
response+="; " + e.toString();
error=true;
}
if (!error) {
response="UDP packet sent="" + message
+ ""; no reply";
byte[] buf= new byte[1024];
packet= new DatagramPacket(buf, buf.length);
try {
dsock.receive(packet);
error=true;
} catch (ArrayIndexOutOfBoundsException e) {
response="server trying to overflow buffer: " + e.toString();
error=true;
} catch (IOException e) {
response="IOException: " + e.toString();
error=true;
}
response= "UDP packet sent="" + message + ""; reply=" + new
String(packet.getData(), 0, packet.getLength());
}
}
}
}
}
+ + +
End of zapatista tribal port scan code
The distribution of the source code for the ++ zapatista tribal port
scan (ZTPS)++ will be followed by the release of a ZTPS Tool on January
15th, 2001 through EDT's home page. Electronic Disturbance Theater