fixing renderText script

This commit is contained in:
2026-06-11 15:14:00 +02:00
parent 3e922883f7
commit 9ad6b15130
302 changed files with 120914 additions and 20 deletions
+120
View File
@@ -0,0 +1,120 @@
class Host {
ArrayList ports;
String addr = "";
boolean isUp = false;
float echo;
ArrayList output;
int x, y;
int id;
boolean testing = false;
String sign;
float w, h;
Host(String _addr, boolean _isUp, float _echo, int _id) {
addr=_addr;
isUp=_isUp;
echo = _echo;
id = _id;
sign = addr;
w = textWidth(sign)+4;
h = 12.0;
x = X;
y = Y;
Y+=12;
output = new ArrayList();
ports = new ArrayList();
if (AUTO_SCAN) {
nmapTarget(this);
testing = true;
}
}
void draw() {
String sign = addr;
if (output.size()>0) {
fill(127);
h = output.size()*10+15;
fill(0);
rect(x-4, y-12, width-10, h);
textAlign(LEFT);
for (int out = 0;out<output.size();out++) {
Port port = (Port)ports.get(out);
port.draw();
fill(#ffffff);
String line = (String)output.get(out);
text(line, x+50, y+out*10);
}
}
if (testing)
fill(#ff2222, 127*(sin(frameCount/5.0)+1.0));
else
if (over()) {
fill(#aa1100);
if (mousePressed && !testing) {
nmapTarget(this);
testing = true;
}
}
else {
fill(0);
}
stroke(#ffcc00);
rect(x-2, y+2, w, -12);
fill(#ffcc00);
textAlign(LEFT);
text(sign, x, y);
textAlign(RIGHT);
text(round(echo*1000.0)/1000.0+"s", width-10, y);
checkOverlaps();
}
boolean over() {
if (mouseX>x && mouseX<x+w && mouseY<y && mouseY > y-10 )
return true;
else
return false;
}
void checkOverlaps() {
for (int i = 0 ; i < hosts.size();i++) {
Host tmp = (Host)hosts.get(i);
if (tmp!=this && tmp.y < y) {
if (y > tmp.y && y < tmp.y+tmp.h+2) {
y +=10;
}
}
}
}
}
+54
View File
@@ -0,0 +1,54 @@
class Nmapper implements Runnable {
String address;
String command = "nmap";
ArrayList output;
Host host;
Nmapper(String _address) {
address = _address;
command += " "+address;
output = new ArrayList();
}
Nmapper(Host h) {
host = h;
address = host.addr;
command += " "+address;
}
void run() {
host.output = new ArrayList();
try {
String line;
Process p = Runtime.getRuntime().exec(command);
BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
int cnt = 0;
while ( (line = input.readLine ()) != null) {
if(QUIET){
if(line.indexOf("shown")==-1){
// ||
// line.indexOf("closed")>-1 ||
// line.indexOf("filtered")>-1) &&
if (line.indexOf("open")>-1){
host.output.add(line);
host.ports.add(new Port(cnt,host));
cnt++;
}
}
}else{
host.output.add(line);
}
//System.out.println(line);
}
host.testing = false;
}
catch(Exception e) {
}
}
}
+64
View File
@@ -0,0 +1,64 @@
class Pinger implements Runnable {
String subnet;
float starttime;
float endtime;
Pinger(String _subnet) {
subnet=""+_subnet;
}
void run2() {
boolean reachable = false;
try
{
InetAddress address = InetAddress.getByName(subnet);
// Try to reach the specified address within the timeout
// periode. If during this periode the address cannot be
// reach then the method returns false.
starttime = millis();
reachable = address.isReachable(10000);
endtime = millis();
if (reachable)
{
hosts.add(new Host(subnet, reachable, endtime-starttime, hosts.size()));
println(subnet);
}
// System.out.println("Is host reachable? " + reachable);
}
catch (Exception e)
{
e.printStackTrace();
}
}
void run(){
String command = "nmap -sP "+subnet;
try {
String line;
Process p = Runtime.getRuntime().exec(command);
BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
while ( (line = input.readLine ()) != null) {
if (line.indexOf("is up")>-1)
{
String echoS = splitTokens(line," ()")[4];
float echo = parseFloat(echoS.substring(0,echoS.length()-1));
hosts.add(new Host(subnet, true, echo, hosts.size()));
//host.output.add(splitTokens(line," ")[0]);
println(line);
}
}
//host.testing = false;
}
catch(Exception e) {
}
}
}
+58
View File
@@ -0,0 +1,58 @@
class Port {
Session session;
Host host;
String line;
int id;
float x, y;
boolean session_running = false;
String name;
int port_num;
Port(int _id, Host _host) {
host = _host;
id = _id;
line = (String)host.output.get(id);
//println(line);
parseLine();
}
void parseLine() {
String [] params = splitTokens(line, "/ ");
port_num = parseInt(params[0]);
name = params[3];
}
void draw() {
y = host.y+id*10+2;
x = host.x+50-4;
if (over()) {
fill(#70A724);
if (mousePressed && !session_running) {
session_running = true;
Thread t = new Thread(new Session(host, this));
t.start();
}
}
else {
fill(#294305);
}
noStroke();
rect(x, y, textWidth(line)+8, -10);
}
boolean over() {
if (mouseX>x && mouseX < x+textWidth(line)+8 && mouseY > y-10 && mouseY < y)
return true;
else
return false;
}
}
+33
View File
@@ -0,0 +1,33 @@
class Session implements Runnable {
Host host;
Port port;
Session(Host _host, Port _port) {
host = _host;
port = _port;
}
void run() {
String command = "terminator -x nc -vv -i59 "+host.addr+" "+port.port_num;
try {
//InvokeScript.execute(command);
String line;
Process p = Runtime.getRuntime().exec(command);
BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
p.waitFor();
while ( (line = input.readLine ()) != null) {
println("reply: "+line);
}
//}
delay(2000);
}
catch(Exception e) {
}
port.session_running = false;
}
}
+63
View File
@@ -0,0 +1,63 @@
void pingAll() {
Y=20;
pingers = new ArrayList();
hosts = new ArrayList();
for (int i =0 ; i < pingers.size();i++) {
Thread t = (Thread)pingers.get(i);
t.stop();
}
for (int i = 1 ; i < 255;i++) {
String addr = prefix+i;
pingers.add(new Thread(new Pinger(addr)));
}
for (int i =0 ; i < pingers.size();i++) {
Thread t = (Thread)pingers.get(i);
t.start();
}
}
void nmapTarget(Host h) {
Thread t = new Thread(new Nmapper(h));
t.start();
}
String getPrefix(String name) {
String _prefix = "";
try {
try {
NetworkInterface ni = NetworkInterface.getByName(name);
Enumeration ia = ni.getInetAddresses();
while (ia.hasMoreElements ()) {
InetAddress elem = (InetAddress)ia.nextElement();
if (elem instanceof Inet4Address) {
//String str = " hostname: "+ elem.getHostAddress();
//println(str);
String str = elem.getHostAddress();
// println(str);
_prefix = ""+str.substring(0, str.lastIndexOf(".")+1);
}
}
}
catch(Exception e) {
println("error vole! "+e);
}
}
catch (NullPointerException e) {
System.out.println("Retrieving Information from NetworkInterface failed");
}
return _prefix;
}
+46
View File
@@ -0,0 +1,46 @@
/////////////////////////////////////
// Lan ping utility by kof, 2012 //
/////////////////////////////////////
String iface = "wlan0";
String prefix;
boolean QUIET = true;
boolean AUTO_SCAN = true;
int X = 10;
int Y = 20;
ArrayList pingers;
ArrayList hosts;
void init() {
frame.removeNotify();
frame.setUndecorated(true);
super.init();
}
void setup() {
size(360, 880, P2D);
textFont(loadFont("SempliceRegular-8.vlw"));
textMode(SCREEN);
frame.setLocation(0, 24);
prefix = getPrefix(iface);
pingAll();
}
void draw() {
background(0);
for (int i =0 ; i < hosts.size();i++) {
Host h = (Host)hosts.get(i);
h.draw();
}
// println(hosts.size());
}