Full Disclosure mailing list archives
[ElectronicSouls] - More JAVA
From: es () hush com
Date: Fri, 29 Nov 2002 09:24:54 -0800
-----BEGIN PGP SIGNED MESSAGE----- Dear List, Sometimes it is important to develop your own daemons, when you can no longer trust the OpenSource products for security. # cat ESDBS.java /* Coded by CraigTM [ElectronicSouls] */ import java.io.*; import java.net.*; import java.util.*; class ESDBS { static final String VERSION="ElectronicSouls DataBase Server v1 alpha"; static ServerSocket ss=null; static Socket incoming=null; static DataInputStream ssin=null; static PrintStream ssout=null; static String split[] = new String[10]; static StringTokenizer token; static int num_tokens; static String line=""; static boolean auth=false; static String PASSWORD="thx"; //file output static FileOutputStream FOS; static PrintStream PS; void StartServer(int Port) { try { ss = new ServerSocket(Port); incoming = ss.accept(); ssin = new DataInputStream(incoming.getInputStream()); ssout = new PrintStream(incoming.getOutputStream()); } catch(IOException e){} }//StartServer() void StopServer() { try { incoming.close(); ss.close(); ssout.close(); ssin.close(); ss=null; ssout=null; ssin=null; incoming=null; } catch(IOException e){} } void show(String db, String pattern) { BufferedReader quelle=null; try { try { quelle=new BufferedReader(new FileReader(db+".db")); while((line=quelle.readLine())!=null) { if(line.indexOf(pattern)>-1) ssout.println(line); if(pattern.equals("*")) ssout.println(line); } quelle.close(); } catch (FileNotFoundException FNF) {ssout.println("Database "+db+" does not exist");} } catch (IOException e){}; }//show void split() { //reset Elements for(int i=0;split[i]!=null;i++) split[i]=null; //split the line token = new StringTokenizer(line, " "); num_tokens = token.countTokens(); //save elements in the array for(int i=0;i<num_tokens;i++) split[i] = token.nextToken(); } //append data to the database file void add(String db, String data) { try { FOS = new FileOutputStream(db+".db",true); PS = new PrintStream(FOS); PS.println(data); PS.close(); FOS.close(); } catch(IOException e){} } //delete everything that's in a DataBase file void del(String db) { try { FOS = new FileOutputStream(db+".db"); PS = new PrintStream(FOS); PS.close(); FOS.close(); } catch(IOException e){} } //check the user input for commands, and do what he wants us to void perform() { String data=""; try { //read in a line from the user line=ssin.readLine(); //split the user input -> fill split[] array split(); //if the user authentificated to the server, do this if(auth) { //[COMMAND] [database] [version] [IP] // split[0] split[1] split[2] split[3] if(split[0].equals("?") || split [0].equals("help")) showmenu(); //del just needs 1 parameter: database if(split[0].equals("del") && split[1]!=null) del(split[1]); //show needs 2 parameters; database,pattern if(split[1]!=null && split[2]!=null) { if(split[0].equals("show")) show(split[1],split[2]); } if(split[1]!=null && split[2]!=null && split[3]!=null) { if(split[0].equals("add")) { for(int i=2;split[i]!=null;i++) data=data+split[i]+" "; data=data.trim(); add(split[1],data); } } }//authentificated //otherwise do this else { //check if a user wants to authentificate if(split[0].equals("auth") && split[1]!=null) { if(split[1].equals(PASSWORD)) { auth=true; ssout.println("Verified. Welcome to the "+VERSION+", member."); } else { ssout.println("Wrong password. Go away, or ...wh33 wi11 h4x0r j00!"); } } }//unauthentificated ssout.print(">"); } catch(IOException e){} }//perform() void showmenu() { ssout.println(VERSION); ssout.println("auth [password]"); ssout.println("add [database] [version] [IP]"); ssout.println("show [database] [pattern]"); ssout.println("del [database]"); ssout.println("exit"); } public static void main(String args[]) { ESDBS e=new ESDBS(); System.out.println("\n\n :::::: ESBDS :::::: "); System.out.println(VERSION); System.out.println(" Coded by CraigTM [ElectronicSouls]"); while(true) { e.StartServer(1337); ssout.print(">"); while(ss != null && incoming != null) { e.perform(); if(split[0].equals("exit"))break; } e.StopServer(); auth=false; } }//main }//class # The Electronic Souls Crew [ElectronicSouls] (c) 2002 "Do you fear me? Do not fear me." -----BEGIN PGP SIGNATURE----- Version: Hush 2.2 (Java) Note: This signature can be verified at https://www.hushtools.com/verify wlMEARECABMFAj3novgMHGVzQGh1c2guY29tAAoJEN5nGqhGcjltwXwAn0BSKj1f/1gU p9GQWEm49sgwe5J1AJ9s6/1fgf5WyJxCraqut/MIzRvcHw== =rxSF -----END PGP SIGNATURE----- Concerned about your privacy? Follow this link to get FREE encrypted email: https://www.hushmail.com/?l=2 Big $$$ to be made with the HushMail Affiliate Program: https://www.hushmail.com/about.php?subloc=affiliate&l=427 _______________________________________________ Full-Disclosure - We believe in it. Charter: http://lists.netsys.com/full-disclosure-charter.html
Current thread:
- [ElectronicSouls] - More JAVA es (Nov 29)