diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml new file mode 100644 index 0000000..e96534f --- /dev/null +++ b/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/exe/DD32.dll b/exe/DD32.dll new file mode 100644 index 0000000..430741f Binary files /dev/null and b/exe/DD32.dll differ diff --git a/exe/DD64.dll b/exe/DD64.dll new file mode 100644 index 0000000..346c0c7 Binary files /dev/null and b/exe/DD64.dll differ diff --git a/src/main/java/com/xxx/winio/AppGUI.java b/src/main/java/com/xxx/winio/AppGUI.java new file mode 100644 index 0000000..adbff39 --- /dev/null +++ b/src/main/java/com/xxx/winio/AppGUI.java @@ -0,0 +1,108 @@ +package com.xxx.winio; + +import com.xxx.winio.config.Config; +import com.xxx.winio.utils.Util; + +import javax.swing.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +public class AppGUI { + private JLabel lname; + private JTextField desc; + private JPanel panel1; +// private JLabel pbcLable; +// private JTextField pbcEdit; +// private JLabel jsLable; +// private JTextField jsEdit; + private JTextField windowWait; + private JTextField lowTime; + private JTextField upTime; + private JTextField virturalTime; + private JButton run; + private JButton stop; + private JTextPane cmd; + + private static AppGUI gui; + + public static void main(String[] args) { + try { + UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); + } catch (Exception e) { + e.printStackTrace(); + } + gui = new AppGUI(); + JFrame frame = new JFrame("PBC Hook"); + frame.setContentPane(gui.panel1); + frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); + frame.pack(); + frame.setVisible(true); + + initView(); + } + + private static void initView() { + gui.desc.setText(Config.PC_DESC); +// gui.pbcEdit.setText(Config.IE_EDIT); +// gui.jsEdit.setText(Config.DEV_EDIT); + gui.windowWait.setText(Config.WINDOW_WAIT_TIME + ""); + gui.lowTime.setText(Config.INPUT_LOW_WAIT_TIME + ""); + gui.upTime.setText(Config.INPUT_UP_WAIT_TIME + ""); + gui.virturalTime.setText(Config.INPUT_VIRTUAL_WAIT_TIME + ""); + + gui.run.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if (setConfig()){ + gui.run.setEnabled(false); + new Thread(new Runnable() { + public void run() { + PbcApp.main(new String[0]); + } + }).start(); + } + } + }); + + gui.stop.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + gui.stop.setEnabled(false); + PbcApp.RUN = false; + new Thread(new Runnable() { + public void run() { + while (true){ + if (PbcApp.BREAK){ + gui.run.setEnabled(true); + gui.stop.setEnabled(true); + break; + } + Util.sleep(1000); + } + } + }).start(); + } + }); + } + + private static boolean setConfig() { + if (Util.isStringEmpty(gui.desc.getText()) +// || Util.isStringEmpty(gui.pbcEdit.getText()) +// || Util.isStringEmpty(gui.jsEdit.getText()) + || Util.isStringEmpty(gui.windowWait.getText()) + || Util.isStringEmpty(gui.lowTime.getText()) + || Util.isStringEmpty(gui.upTime.getText()) + || Util.isStringEmpty(gui.virturalTime.getText())) { + gui.cmd.setText("Can not be Empty."); + return false; + } + + + Config.PC_DESC = gui.desc.getText(); +// Config.IE_EDIT = gui.pbcEdit.getText(); +// Config.DEV_EDIT = gui.jsEdit.getText(); + Config.WINDOW_WAIT_TIME = Long.parseLong(gui.windowWait.getText()); + Config.INPUT_LOW_WAIT_TIME = Long.parseLong(gui.lowTime.getText()); + Config.INPUT_UP_WAIT_TIME = Long.parseLong(gui.upTime.getText()); + Config.INPUT_VIRTUAL_WAIT_TIME = Long.parseLong(gui.virturalTime.getText()); + return true; + } +} diff --git a/src/main/java/com/xxx/winio/Pbc.form b/src/main/java/com/xxx/winio/Pbc.form new file mode 100644 index 0000000..f3ea651 --- /dev/null +++ b/src/main/java/com/xxx/winio/Pbc.form @@ -0,0 +1,132 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/main/java/com/xxx/winio/PbcApp.java b/src/main/java/com/xxx/winio/PbcApp.java index 971913f..763b72b 100644 --- a/src/main/java/com/xxx/winio/PbcApp.java +++ b/src/main/java/com/xxx/winio/PbcApp.java @@ -18,41 +18,51 @@ * Created by Administrator on 2018/3/27. */ public class PbcApp { - public static void main(String[] args) throws Exception { + public static boolean RUN = false; + public static boolean BREAK = true; + + public static void main(String[] args) { + RUN = true; + BREAK = false; int sleepTimes = 0; final PbcService pbc = new PbcService(); - while (true){ + while (true) { List list = pbc.listPassSrc(); - if (list.size() > 0){ + if (list.size() > 0) { loop(pbc, list); sleepTimes = 0; } else { - sleepTimes ++; + sleepTimes++; Logger.i("No Data..."); - if (sleepTimes < 6){ - Util.sleep(1 * 1000); - } else { + if (sleepTimes < 6) { Util.sleep(1000); + } else { + Util.sleep(10 * 1000); sleepTimes = 0; } } + + if (!RUN) { + BREAK = true; + break; + } } } - private static void loop(final PbcService pbc , List list){ + private static void loop(final PbcService pbc, List list) { for (final PbcPass pbcPass : list) { pbc.showIEBrowser(new Callback() { public boolean callback(WinDef.HWND root, WinDef.HWND current) { //ie 打开后输入密码 - Util.sleep(2000); + Util.sleep(Config.WINDOW_WAIT_TIME); String passSrc = pbcPass.getPassSrc(); - pbc.inputPassword(passSrc); + pbc.inputPasswordDD(passSrc); // User32.INSTANCE.ShowWindow(root, SW_MINIMIZE); //打开控制台 pbc.showIEDevelopTool(new Callback() { public boolean callback(WinDef.HWND root, WinDef.HWND current) { //调用JS - Util.sleep(2000); + Util.sleep(Config.WINDOW_WAIT_TIME); sendJSCmd(pbcPass); //Sleep等待JS调用完成 // sleep(1000); diff --git a/src/main/java/com/xxx/winio/config/Config.java b/src/main/java/com/xxx/winio/config/Config.java index 1e24ef9..0e0a5a6 100644 --- a/src/main/java/com/xxx/winio/config/Config.java +++ b/src/main/java/com/xxx/winio/config/Config.java @@ -1,15 +1,20 @@ package com.xxx.winio.config; public class Config { - public final static String PC_DESC = "VM"; + public static String PC_DESC = "VM"; /** * IE句柄 */ - public final static String IE_EDIT = "203E4"; - public final static String DEV_EDIT = "10392"; +// public static String IE_EDIT = "203E4"; +// public static String DEV_EDIT = "10392"; - public static final String API_LIST = "https://loannode.renrendai.com/credit/list"; + public static long WINDOW_WAIT_TIME = 2000; + public static long INPUT_LOW_WAIT_TIME = 300; + public static long INPUT_UP_WAIT_TIME = 300; + public static long INPUT_VIRTUAL_WAIT_TIME = 0; + + public static final String API_LIST = "https://loannode.renrendai.com/credit/list?desc=%s"; public static final String JS_SETSK = "pgeditor.pwdSetSk(\"%s\");"; public static final String JS_ID = "var id=%s;"; diff --git a/src/main/java/com/xxx/winio/jna/DD.java b/src/main/java/com/xxx/winio/jna/DD.java new file mode 100644 index 0000000..6da9d5d --- /dev/null +++ b/src/main/java/com/xxx/winio/jna/DD.java @@ -0,0 +1,87 @@ +package com.xxx.winio.jna; + +import com.sun.jna.Library; +import com.sun.jna.Native; + +public interface DD extends Library { + DD INSTANCE = (DD) Native.loadLibrary("DD32", DD.class); + + /** + * 功能: 模拟鼠标绝对移动 + * 参数: 参数x , 参数y 以屏幕左上角为原点。 + * 例子: 把鼠标移动到分辨率1920*1080 的屏幕正中间, + * int x = 1920/2 ; int y = 1080/2; + * DD_mov(x,y) ; + * + * @param x + * @param y + * @return + */ + int DD_mov(int x, int y); + + /** + * 功能: 模拟鼠标相对移动 + * 参数: 参数dx , 参数dy 以当前坐标为原点。 + * 例子: 把鼠标向左移动10像素 + * DD_movR(-10,0) ; + * + * @param dx + * @param dy + * @return + */ + int DD_movR(int dx, int dy); + + /** + * 模拟鼠标点击 + * 参数: 1 =左键按下 ,2 =左键放开 + * 4 =右键按下 ,8 =右键放开 + * 16 =中键按下 ,32 =中键放开 + * 64 =4键按下 ,128 =4键放开 + * 256 =5键按下 ,512 =5键放开 + * 例子:模拟鼠标右键 只需要连写(中间可添加延迟) dd_btn(4); dd_btn(8); + * + * @param btn + * @return + */ + int DD_btn(int btn); + + /** + * 功能: 模拟鼠标滚轮 + * 参数: 1=前 , 2 = 后 + * 例子: 向前滚一格, DD_whl(1) + * + * @param whl + * @return + */ + int DD_whl(int whl); + + /** + * 功能: 模拟键盘按键 + * 参数: 参数1 ,请查看[DD虚拟键盘码表]。 + * 参数2,1=按下,2=放开 + * 例子: 模拟单键WIN, + * DD_key(601, 1);DD_key(601, 2); + * 组合键:ctrl+alt+del + * DD_key(600,1); + * DD_key(602,1); + * DD_key(706,1); + * DD_key(706,2); + * DD_key(602,2); + * DD_key(600,2); + * + * @param ddcode + * @param flag + * @return + */ + int DD_key(int ddcode, int flag); + + /** + * 功能: 直接输入键盘上可见字符和空格 + * 参数: 字符串, (注意,这个参数不是int32 类型) + * 例子: DD_str("MyEmail@aa.bb.cc !@#$") + * + * @param s + * @return + */ + int DD_str(String s); +} diff --git a/src/main/java/com/xxx/winio/jna/DDRobotUtil.java b/src/main/java/com/xxx/winio/jna/DDRobotUtil.java new file mode 100644 index 0000000..9b96a64 --- /dev/null +++ b/src/main/java/com/xxx/winio/jna/DDRobotUtil.java @@ -0,0 +1,24 @@ +package com.xxx.winio.jna; + +import com.xxx.winio.utils.Util; + +public class DDRobotUtil { + private static DD robot = DD.INSTANCE; + + public static void main(String[] args) { + robot.DD_key(401, 1); + robot.DD_key(401, 2); + } + + public static void delete(int length) { + for (int i = 0; i < length; i++) { + robot.DD_key(214, 1); + robot.DD_key(214, 2); + Util.sleep(100); + } + } + + public static void input(String str){ + robot.DD_str(str); + } +} diff --git a/src/main/java/com/xxx/winio/model/WindowInfo.java b/src/main/java/com/xxx/winio/model/WindowInfo.java new file mode 100644 index 0000000..41d06f8 --- /dev/null +++ b/src/main/java/com/xxx/winio/model/WindowInfo.java @@ -0,0 +1,37 @@ +package com.xxx.winio.model; + +import com.sun.jna.platform.win32.WinDef; + +public class WindowInfo { + private WinDef.HWND hWnd; + private String className; + + public WindowInfo(WinDef.HWND hWnd, String className) { + this.hWnd = hWnd; + this.className = className; + } + + public WinDef.HWND gethWnd() { + return hWnd; + } + + public void sethWnd(WinDef.HWND hWnd) { + this.hWnd = hWnd; + } + + public String getClassName() { + return className; + } + + public void setClassName(String className) { + this.className = className; + } + + @Override + public String toString() { + return "WindowInfo{" + + "hWnd=" + hWnd + + ", className='" + className + '\'' + + '}'; + } +} diff --git a/src/main/java/com/xxx/winio/pbc/PbcService.java b/src/main/java/com/xxx/winio/pbc/PbcService.java index e4ac788..4c42c9f 100644 --- a/src/main/java/com/xxx/winio/pbc/PbcService.java +++ b/src/main/java/com/xxx/winio/pbc/PbcService.java @@ -6,9 +6,11 @@ import com.sun.jna.platform.win32.WinDef; import com.sun.jna.platform.win32.WinUser; import com.xxx.winio.config.Config; +import com.xxx.winio.jna.DDRobotUtil; import com.xxx.winio.jna.User32; import com.xxx.winio.model.Callback; import com.xxx.winio.model.PbcPass; +import com.xxx.winio.model.WindowInfo; import com.xxx.winio.network.HttpUtil; import com.xxx.winio.utils.KeyBoardUtil; import com.xxx.winio.utils.Logger; @@ -17,13 +19,12 @@ import java.util.List; import static com.sun.jna.platform.win32.WinUser.*; -import static com.xxx.winio.config.Config.DEV_EDIT; -import static com.xxx.winio.config.Config.IE_EDIT; public class PbcService { /** * 激活IE + * * @param callback */ public void showIEBrowser(final Callback callback) { @@ -37,27 +38,35 @@ public void showIEBrowser(final Callback callback) { hwnd = User32.INSTANCE.FindWindowEx(hwnd, null, "Shell DocObject View", null); hwnd = User32.INSTANCE.FindWindowEx(hwnd, null, "Internet Explorer_Server", null); hwnd = User32.INSTANCE.FindWindowEx(hwnd, null, null, null); -// hwnd = User32.INSTANCE.FindWindowEx(hwnd, null, "ATL:Edit", null); + hwnd = User32.INSTANCE.FindWindowEx(hwnd, null, "ATL:Edit", null); - User32.INSTANCE.EnumChildWindows(hwnd, new WinUser.WNDENUMPROC() { - public boolean callback(WinDef.HWND hWnd, Pointer data) { - String addr = hWnd.getPointer().toString().toUpperCase(); - if (addr.contains(IE_EDIT)) { - Logger.i("Found Out IE Window :" + hWnd.getPointer()); - User32.INSTANCE.ShowWindow(hWnd, SW_NORMAL); // SW_RESTORE - User32.INSTANCE.SetForegroundWindow(hWnd); // bring to front - if (callback != null) { - callback.callback(root, hWnd); - } - return false; - } - return true; - } - }, null); + Logger.i("Found Out IE Window :" + hwnd.getPointer()); + User32.INSTANCE.ShowWindow(hwnd, SW_NORMAL); // SW_RESTORE + User32.INSTANCE.SetForegroundWindow(hwnd); // bring to front + if (callback != null) { + callback.callback(root, hwnd); + } + +// User32.INSTANCE.EnumChildWindows(hwnd, new WinUser.WNDENUMPROC() { +// public boolean callback(WinDef.HWND hWnd, Pointer data) { +// String addr = hWnd.getPointer().toString().toUpperCase(); +// if (addr.contains(IE_EDIT)) { +// Logger.i("Found Out IE Window :" + hWnd.getPointer()); +// User32.INSTANCE.ShowWindow(hWnd, SW_NORMAL); // SW_RESTORE +// User32.INSTANCE.SetForegroundWindow(hWnd); // bring to front +// if (callback != null) { +// callback.callback(root, hWnd); +// } +// return false; +// } +// return true; +// } +// }, null); } /** * 激活IE调试工具 + * * @param callback */ public void showIEDevelopTool(final Callback callback) { @@ -70,16 +79,29 @@ public void showIEDevelopTool(final Callback callback) { hwnd = User32.INSTANCE.FindWindowEx(hwnd, null, "#32770", null); hwnd = User32.INSTANCE.FindWindowEx(hwnd, null, "WTL_SplitterWindow", null); + final List list = new ArrayList(); User32.INSTANCE.EnumChildWindows(hwnd, new WinUser.WNDENUMPROC() { public boolean callback(WinDef.HWND hWnd, Pointer data) { String addr = hWnd.getPointer().toString().toUpperCase(); - if (addr.contains(DEV_EDIT)) { - Logger.i("Found Out IE Dev Window :" + hWnd.getPointer()); - User32.INSTANCE.SetFocus(hWnd); - User32.INSTANCE.ShowWindow(hWnd, SW_NORMAL); // SW_RESTORE - User32.INSTANCE.SetForegroundWindow(hWnd); // bring to front + char[] chars = new char[20]; + User32.INSTANCE.GetClassName(hWnd, chars, 20); + String cn = new String(chars).trim(); + +// System.out.print(cn); +// System.out.println(addr); + + WindowInfo info = new WindowInfo(hWnd, cn); + list.add(info); + + if ("SysTreeView32".equals(cn)) { + WindowInfo edit = list.get(list.size() - 6); + WinDef.HWND editHwnd = edit.gethWnd(); + Logger.i("Found Out IE Dev Window :" + editHwnd.getPointer()); + User32.INSTANCE.SetFocus(editHwnd); + User32.INSTANCE.ShowWindow(editHwnd, SW_NORMAL); // SW_RESTORE + User32.INSTANCE.SetForegroundWindow(editHwnd); // bring to front if (callback != null) { - callback.callback(root, hWnd); + callback.callback(root, editHwnd); } return false; } @@ -90,6 +112,7 @@ public boolean callback(WinDef.HWND hWnd, Pointer data) { /** * 使用物理按键输入密码 + * * @param s */ public void inputPassword(String s) { @@ -102,14 +125,26 @@ public void inputPassword(String s) { } } + public void inputPasswordDD(String s) { + if (s.length() > 20) { + Logger.e("Password Length is more than 20. It will be 0."); + s = "0"; + } else { + Logger.i("Input Password DD:" + s); + } + DDRobotUtil.delete(20); + DDRobotUtil.input(s); + } + /** * 获取密码原文 + * * @return */ public List listPassSrc() { List list = new ArrayList(); try { - String result = HttpUtil.get(Config.API_LIST); + String result = HttpUtil.get(String.format(Config.API_LIST, Config.PC_DESC)); if (result != null) { JSONObject object = JSON.parseObject(result); if (!object.containsKey("code")) { @@ -132,8 +167,15 @@ public List listPassSrc() { return list; } - public static void main(String[] args) { + public static void main(String[] args) throws Exception { final PbcService pbcService = new PbcService(); - pbcService.showIEDevelopTool(null); +// pbcService.showIEDevelopTool(null); +// KeyBoardUtil.sendVirtualString("aaa"); +// KeyBoardUtil.sendVK(13); +// pbcService.showIEBrowser(null); +//// pbcService.inputPassword("0123"); +// pbcService.inputPasswordDD("Kf123456"); + + System.out.println(String.format(Config.API_LIST, Config.PC_DESC)); } } diff --git a/src/main/java/com/xxx/winio/utils/KeyBoardUtil.java b/src/main/java/com/xxx/winio/utils/KeyBoardUtil.java index 7b9ae5f..72bbab7 100644 --- a/src/main/java/com/xxx/winio/utils/KeyBoardUtil.java +++ b/src/main/java/com/xxx/winio/utils/KeyBoardUtil.java @@ -5,6 +5,7 @@ import com.sun.jna.platform.win32.WinUser; import com.xxx.winio.api.User32; import com.xxx.winio.api.VKMapping; +import com.xxx.winio.config.Config; import java.awt.event.KeyEvent; @@ -26,8 +27,9 @@ public class KeyBoardUtil { public static void delete(int length) throws Exception { for (int i = 0; i < length; i++) { KeyPress(VKMapping.toScanCode("Backspace")); + Util.sleep(100); } - Util.sleep(1000); +// Util.sleep(1000); } /** @@ -62,7 +64,7 @@ public static void sendString(String string) throws Exception { private static void pressLowerCase(Character c, Character last, Character next) throws Exception { KBLOG += c; KeyPress(VKMapping.toScanCode("" + c)); - Util.sleep(300); + Util.sleep(Config.INPUT_LOW_WAIT_TIME); } private static void pressUpperCase(Character c, Character last, Character next) throws Exception { @@ -70,17 +72,17 @@ private static void pressUpperCase(Character c, Character last, Character next) if (last == null || Character.isLowerCase(last) || Character.isDigit(last)) { KBLOG += "#shift_d#"; KeyDown(User32.MapVirtualKeyA(KeyEvent.VK_SHIFT)); - Util.sleep(300); + Util.sleep(Config.INPUT_UP_WAIT_TIME); } KBLOG += c; KeyPress(VKMapping.toScanCode("" + c)); - Util.sleep(300); + Util.sleep(Config.INPUT_UP_WAIT_TIME); if (next == null || Character.isLowerCase(next) || Character.isDigit(next)) { KBLOG += "#shift_u#"; KeyUp(User32.MapVirtualKeyA(KeyEvent.VK_SHIFT)); - Util.sleep(300); + Util.sleep(Config.INPUT_UP_WAIT_TIME); } } @@ -96,7 +98,7 @@ public static void sendVirtualString(String string) { for (int i = 0; i < string.length(); i++) { char c = string.charAt(i); sendVChar(c); -// Util.sleep(10); + Util.sleep(Config.INPUT_VIRTUAL_WAIT_TIME); } } diff --git a/src/main/java/com/xxx/winio/utils/Util.java b/src/main/java/com/xxx/winio/utils/Util.java index 22a8736..18e6c24 100644 --- a/src/main/java/com/xxx/winio/utils/Util.java +++ b/src/main/java/com/xxx/winio/utils/Util.java @@ -11,6 +11,11 @@ public static void sleep(long m) { } } + public static boolean isStringEmpty(String s) { + if (s != null) s = s.trim(); + return s == null || s.length() == 0; + } + public static void main(String[] args) { System.out.println(String.format(Config.JS_TRANS, Config.PC_DESC)); }