import javax.microedition.lcdui.*; import javax.microedition.midlet.*; import javax.microedition.rms.*; import java.io.*; import javax.microedition.io.file.*; import javax.microedition.io.*; public class Midlet extends MIDlet implements CommandListener { Form f = new Form("FireWall v1.2"); Form f1 = new Form("Hướng dẫn:"); TextField tf = new TextField("Pass or Link to File:", "", 500, 0); Command newp = new Command("Mật khẩu mới", 4, 2); Command doip = new Command("Đổi mật khẩu", 4, 3); Command ok = new Command("Truy cập", 4, 1); Command hd = new Command("Hướng dẫn", 4, 4); Command thoat = new Command("Thoát", 7, 20); Command back = new Command("Trở lại", 7, 19); Display d = Display.getDisplay(this); RecordStore rs; public void startApp() { f.append(tf); f.setTicker(new Ticker("Firewall v1.2 by SystemERROR thank to ServantOfEvil, darkrai, nhoktapyeu, poker....")); f.append("Đọc kĩ hướng dẫn sử dụng trước khi dùng!"); f.addCommand(ok); f.addCommand(newp); f.addCommand(doip); f.addCommand(hd); f.addCommand(thoat); f.setCommandListener(this); f1.append("Trước khi sử dụng bạn cần phải đặt mật khẩu mới!\nĐể đặt mật khẩu mới bạn hãy tạo một file gốc là txt bên trong chứa mật khẩu cần tạo.\nTiếp theo hãy chuyển file chứa pass tới 1link an toàn (vd E:/sencurity/system.error)lưu ý: lên nhớ đây là link quan trọng như một mật khẩu cấp 2 quyết định bạn có đổi mk đc nữa hay không.\nVào app mod firewall nhập địa chỉ đến file txt vừa tạo rồi nhấn mật khẩu mới, máy báo đặt mật khẩu mới thành công là được rồi, khi vào app nhập mật khẩu vào ô rồi nhấn truy cập! À mà lên xoá link tới pass.txt để khỏi lộ pass.\nCòn muốn đổi pass trước tiên phải khôi phục lại link tới file pass.txt(coi như mật khẩu cấp 2, phải nhập đúng không sai 1kí tự) trong chứa mật khẩu mới, ở destop nhập mật khẩu cũ rồi nhấn đổi mật khẩu, máy báo đổi mật khẩu thành công là ok!"); f1.addCommand(back); f1.setCommandListener(this); d.setCurrent(f); } public void pauseApp() { } public void destroyApp(boolean b) { try { int len = rs.getNumRecords(); if (len >= 3) { for (int i = 3; i <= len; i++) { rs.deleteRecord(i); } } else { notifyDestroyed(); } } catch(Exception e) { d.setCurrent(new Alert("warning", e.toString(), null, AlertType.WARNING)); } } public void commandAction(Command cm, Displayable dp) { try { rs = RecordStore.openRecordStore("password", true); } catch(Exception e) { f.append("" + e.toString()); } String ip = tf.getString(); if (cm == thoat) destroyApp(true); if (cm == hd) d.setCurrent(f1); if (cm == back) d.setCurrent(f); if (cm == newp) { try { FileConnection fc = (FileConnection) Connector.open("file:///" + ip); if (fc.exists()) { InputStream is = fc.openInputStream(); StringBuffer s = new StringBuffer(); int c; while ((c = is.read()) != -1) s.append((char) c); is.close(); byte[] n = s.toString().getBytes(); byte[] m = ip.getBytes(); rs.addRecord(n, 0, n.length); rs.addRecord(m, 0, m.length); rs.closeRecordStore(); d.setCurrent(new Alert("Thông báo", "Đặt mật khẩu thành công!", null, AlertType.WARNING)); } else { d.setCurrent(new Alert("Lỗi", "Link tới file chứa pass sai!", null, AlertType.WARNING)); } } catch(Exception e) { d.setCurrent(new Alert("Lỗi", "Không thể tạo mật khẩu mới!", null, AlertType.WARNING)); } } if (cm == doip) { try { byte[] b = rs.getRecord(1); byte[] g = rs.getRecord(2); if (new String(b, 0, b.length).equals(tf.getString())) { FileConnection fc = (FileConnection) Connector.open("file:///" + new String(g, 0, g.length)); InputStream is = fc.openInputStream(); StringBuffer s = new StringBuffer(); int c; while ((c = is.read()) != -1) s.append((char) c); is.close(); byte[] h = s.toString().getBytes(); rs.setRecord(1, h, 0, h.length); d.setCurrent(new Alert("Thông báo", "Thay đổi mật khẩu thành công!", null, AlertType.WARNING)); } else { d.setCurrent(new Alert("Lỗi", "Mật khẩu cũ sai!", null, AlertType.WARNING)); } } catch(Exception e) { d.setCurrent(new Alert("Lỗi", "Không thể tạo mật khẩu mới!", null, AlertType.WARNING)); } } if (cm == ok) { try { byte[] ch = rs.getRecord(1); String ss = new String(ch, 0, ch.length); if (ss.equals(ip)) { d.setCurrent(new Alert("Thông báo", "Truy cập thành công!", null, AlertType.WARNING)); //thiết lập địa chỉ tiếp theo } else { d.setCurrent(new Alert("Lỗi", "Mật khẩu sai!", null, AlertType.WARNING)); } } catch(Exception e) { d.setCurrent(new Alert("Lỗi", "Bạn phải tạo mật khẩu mới!", null, AlertType.WARNING)); } } } }