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"); Form f1 = new Form("Hướng dẫn:"); TextField tf = new TextField("Firewall:", "", 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 by SystemERROR thank to ServantOfEvil, darkrai, nhoktapyeu, poker . . .")); f.append("- Nếu là lần đầu truy cập vui lòng xem hướng dẫn!"); f.addCommand(ok); f.addCommand(newp); f.addCommand(doip); f.addCommand(hd); f.addCommand(thoat); f.setCommandListener(this); f1.append("HÃY LÀM TUẦN TỰ CÁC BƯỚC SAU ĐỂ FIREWALL HOẠT ĐỘNG ĐÚNG\nI. Tạo mật khẩu mới\n1.tạo 1 file txt tên tuỳ bạn, bên trong có chứa pass bạn muốn đặt lưu lại và nhét vào bất cứ đâu bạn muốn, nhớ là phải nhớ đường dẫn và tên file bạn đặt.txt đến khi xoá app\n2. Vào ứng dụng đã mod firewall nhập link vào ô firewall (vd có link là E://pass.txt) nhấn tuỳ chọn - mật khẩu mới\n3. Máy báo đặt mật khẩu thành công thì thoát ra vào lại, nhập mật khẩu đã lưu vào file txt và nhấn truy cập\n4. Xoá file txt lưu pass để chống soi!\nII. Đổi mật khẩu\n1. Để đổi pass bạn cần nhớ link đến đường dẫn đã đặt pass ban đầu vd E:///pass.txt\n2. Tạo file txt tên như lần đầu bạn tạo pass và link tới đó cũng vậy, nội dung là mật khẩu mới\n3. Nhấn đổi mật khẩu và máy báo đổi mk thành côg là ok"); f1.addCommand(back); f1.setCommandListener(this); d.setCurrent(f); } public void pauseApp() { } public void destroyApp(boolean b) { notifyDestroyed(); } 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(f); if (cm == newp) { try { FileConnection fc = (FileConnection) Connector.open("file:///" + ip); 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)); } 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); if (new String(b, 0, b.length).equals(tf.getString())) { FileConnection fc = (FileConnection) Connector.open(new String(rs.getRecord(2), 0, rs.getRecord(2).length)); InputStream is = fc.openInputStream(); StringBuffer s = new StringBuffer(); int c; while ((c = is.read()) != -1) s.append((char) c); is.close(); byte[] g = s.toString().getBytes(); rs.setRecord(1, g, 0, g.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)); } 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)); } } } }