// Javas tehtud fake finger server import java.io.*; import java.net.*; import java.util.Date; public class Finger{ public static void main(String argumendid[]) throws IOException{ ServerSocket ss=new ServerSocket(79); while(true){ new Fingerloim(ss.accept()); } } } class Fingerloim extends Thread{ Socket sc; public Fingerloim(Socket uus_sc){ sc=uus_sc; start(); } public void run(){ String segased="~!#¤%&/()=?`'*üõäöÕÜÖÄ£$€[]]}{½.:,;+-_<>|"; try{ PrintWriter error=new PrintWriter(sc.getOutputStream(), true); PrintWriter valja=new PrintWriter(sc.getOutputStream(), true); BufferedReader sisse=new BufferedReader( new InputStreamReader(sc.getInputStream()) ); String nimi=sisse.readLine(); valja.println("QNX Realtime Platform Server (built 0.98)."); valja.println("(C) Copyright 1985-2001 QNX Corp."); valja.println("Finger connection established..."); valja.println(""); valja.println("[mail.hk.tpu.ee]"); // --- Logi start --- PrintWriter logi=new PrintWriter( new FileWriter("finger.log", true) ); logi.println("Uuriti infot kasutajanime: "+nimi+" kohta "+new Date()); logi.close(); // --- Logi lõpp --- boolean leidub=false; for(int i=0; i=0)leidub=true; } if(leidub==true){ valja.println(""); valja.println("No such user..."); } else{ if(nimi.equals("root")){ valja.println(""); valja.println("Finger connection refused..."); valja.println("You cannot finger root user"); valja.println("Finger connection closed..."); } else if(nimi.equals("mail")){ valja.println(""); valja.println("Finger connection refused..."); valja.println("You cannot finger Mail user"); valja.println("Finger connection closed..."); } else if(nimi.equals("apache")){ valja.println(""); valja.println("Finger connection refused..."); valja.println("You cannot finger Apache user"); valja.println("Finger connection closed..."); } else if(nimi.equals("news")){ valja.println(""); valja.println("Finger connection refused..."); valja.println("You cannot finger News user"); valja.println("Finger connection closed..."); } else if(nimi.equals("")){ valja.println(""); valja.println("Please specify user name."); } else if(nimi.equals("admin")){ valja.println(""); valja.println("No such user"); } else if(nimi.equals("administrator")){ valja.println(""); valja.println("No such user"); } else if(nimi.equals("kala")){ valja.println(""); valja.println("No such user"); } else if(nimi.startsWith("kala")){ valja.println(""); valja.println("No such user"); } else if(nimi.equals("samba")){ valja.println(""); valja.println("Finger connection refused..."); valja.println("You cannot finger Samba user"); valja.println("Finger connection closed..."); } else{ boolean kolemas=false; boolean polemas=false; File kataloog=new File("users"); if(kataloog.isDirectory()){ String[] failid=kataloog.list(); for(int i=0; i