Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package dbclient;
- import java.awt.EventQueue;
- import javax.swing.JFrame;
- import javax.swing.JLabel;
- import javax.swing.ImageIcon;
- import java.awt.Color;
- import java.awt.Font;
- import java.awt.Toolkit;
- import java.io.BufferedReader;
- import java.io.File;
- import java.io.InputStreamReader;
- import java.nio.file.Files;
- import java.nio.file.Path;
- import java.nio.file.attribute.BasicFileAttributeView;
- import java.nio.file.attribute.BasicFileAttributes;
- import java.util.Objects;
- import java.util.Timer;
- import java.util.TimerTask;
- import javax.swing.JTextArea;
- import javax.swing.event.ChangeListener;
- import javax.swing.event.DocumentListener;
- import javax.swing.JButton;
- import javax.swing.JTextField;
- public class Gui {
- private static String currentsteamId = null, realSteamId = null;
- private static long temp = 0;
- public static int activeUserDec = 0;
- private JFrame frame;
- private JTextField textField;
- /**
- * Launch the application.
- */
- public static void main(String[] args) throws Exception {
- System.out.println("the steam needed to be close and after open the cs1.6 original(steam)");
- //
- if(!findRegQuery(2, 26, "reg query " + "HKCU\\Software\\Valve\\Steam\\ActiveProcess").equals("0")) System.exit(1);
- while(findRegQuery(2, 26, "reg query " + "HKCU\\Software\\Valve\\Steam\\ActiveProcess").equals("0"));
- long time = System.currentTimeMillis();
- temp = time;
- while(time < temp + 20 * 1000) time += (System.currentTimeMillis() - time);
- realSteamId = extricateSteamId();
- System.out.println(realSteamId);
- //when steam opened
- Thread csRunning = new Thread(new Runnable() {
- @Override
- public void run() {
- try {
- int c = 0;
- S1Task task1 = null;
- //if cs 1.6 original on
- while(findRegQuery(5, 30, "reg query " + "HKCU\\Software\\Valve\\Steam\\Apps\\10").equals("1")) {
- if(c == 0) {
- currentsteamId = extricateSteamId();
- if(!realSteamId.equals(currentsteamId)) break;
- String steamPath = findRegQuery(9, 27, "reg query " + "HKCU\\Software\\Valve\\Steam\\ActiveProcess");
- String ssPath = (steamPath + "\\userdata" + "\\" + activeUserDec + "\\760\\remote\\10\\screenshots").replaceAll("\\\\", "/");
- //finally get access to screenshot folder
- File ssFolder = new File(ssPath);
- //first length when the program start
- long filesSz = doEachFile(ssFolder, "length");
- Timer timer1 = new Timer();
- //send the screenshot folder and first length when the program start
- task1 = new S1Task(ssFolder, filesSz);
- timer1.schedule(task1, 1000, 10*1000);
- }
- else if(c == 1) {
- System.out.println("IN WHILE ID");
- currentsteamId = extricateSteamId();
- if(!realSteamId.equals(currentsteamId)) break;
- continue;
- }
- c++;
- }
- System.exit(1);
- } catch (Exception x1) {
- x1.printStackTrace();
- }
- }
- });
- csRunning.start();
- EventQueue.invokeLater(new Runnable() {
- public void run() {
- try {
- Gui window = new Gui();
- window.frame.setVisible(true);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- });
- }
- //find some String from registry by using: c = line num, s = where to start the sub String, regQuery = command reg query to cmd
- public static String findRegQuery(int c, int s, String regQuery) throws Exception {
- String line = null;
- int i = 0;
- Runtime runtime = Runtime.getRuntime();
- Process cmd = runtime.exec(regQuery);
- BufferedReader in = new BufferedReader(new InputStreamReader(cmd.getInputStream()));
- while ((line = in.readLine()) != null) {
- if(i == c) break;
- i++;
- }
- in.close();
- return line.substring(s);
- }
- public static String extricateSteamId() throws Exception {
- String steamId = null;
- //find active user in hexadecimal
- String activeUserHex = findRegQuery(6, 33, "reg query " + "HKCU\\Software\\Valve\\Steam\\ActiveProcess");
- //convert hexadecimal to decimal
- activeUserDec = Integer.parseInt(activeUserHex, 16);
- //convert int to String
- String activeUserString = String.valueOf(activeUserDec);
- int lActiveUser = activeUserString.length();
- //the last digit (String)
- String lastDigitS = activeUserString.substring(lActiveUser - 1 , lActiveUser);
- //convert the last digit to int
- int lastDigit = Integer.parseInt(lastDigitS);
- int tempActiveUserDec = activeUserDec;
- //if the last digit is: even-num OR odd-num
- if(lastDigit % 2 == 0) {
- tempActiveUserDec /= 2;
- return steamId = "STEAM_0:0:" + tempActiveUserDec;
- } else {
- tempActiveUserDec = (activeUserDec -= 1) / 2;
- return steamId = "STEAM_0:1:" + tempActiveUserDec;
- }
- }
- //do the command on the folder files
- public static long doEachFile(File folder, String command) {
- long returnValue = 0;
- if(command.equals("length")) for(File file : folder.listFiles()) if(file.isFile()) returnValue += file.length();
- if(command.equals("count")) for(File file : folder.listFiles()) if(file.isFile()) returnValue += 1;
- return returnValue;
- }
- //return creation time of file
- public static long fileCreationDate(File file) throws Exception {
- Path p = file.toPath();
- BasicFileAttributes view = Files.getFileAttributeView(p, BasicFileAttributeView.class).readAttributes();
- String tempCd = view.creationTime().toString().replaceAll("-", "0").replaceAll(":", "0").replaceAll("T", "0");
- tempCd = tempCd.substring(0, 19);
- long creationDate = Long.parseLong(tempCd);
- return creationDate;
- }
- //compare files creation and sorting by date
- public static File sortFolder(File folder) throws Exception {
- File[] listFiles = folder.listFiles();
- File filex = null;
- long created = 0;
- int result = 0;
- int index = 0;
- if(doEachFile(folder, "count") == 0) return filex;
- else {
- //find the first file
- for(int i = 0; i < listFiles.length - 1; i++) {
- if(listFiles[i].isFile()) {
- created = fileCreationDate(listFiles[i]);
- filex = listFiles[i];
- index = i;
- break;
- }
- }
- if(doEachFile(folder, "count") == 1) return filex;
- else {
- //compare and find the last file that was created
- for(int i = (index + 1); i < listFiles.length - 1; i++) {
- if(listFiles[i].isFile()) {
- result = Long.compare(fileCreationDate(listFiles[i]), created);
- if(result > 0) {
- created = fileCreationDate(listFiles[i]);
- filex = listFiles[i];
- }
- }
- }
- return filex;
- }
- }
- }
- /**
- * Create the application.
- */
- public Gui() {
- initialize();
- }
- /**
- * Initialize the contents of the frame.
- */
- private void initialize() {
- frame = new JFrame();
- frame.setBounds(100, 100, 564, 337);
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- frame.getContentPane().setLayout(null);
- frame.setTitle("Frag Anti-Cheat: Corona Version");
- ImageIcon imgicon = new ImageIcon("C:\\Users\\doron\\eclipse-workspace\\dbclient\\img\\4.jpg");
- frame.setIconImage(imgicon.getImage());
- frame.setResizable(false);
- JLabel l1 = new JLabel("");
- l1.setIcon(new ImageIcon("C:\\Users\\doron\\eclipse-workspace\\dbclient\\img\\5.png"));
- l1.setBounds(1, 196, 200, 120);
- frame.getContentPane().add(l1);
- JTextArea t1 = new JTextArea();
- t1 .setFont(new Font("Monospaced", Font.BOLD, 12));
- t1 .setBounds(408, 93, 138, 20);
- t1.setText(currentsteamId );
- t1.setEditable(false);
- frame.getContentPane().add(t1 );
- JLabel l2 = new JLabel("סטיים איידי");
- l2.setFont(new Font("Tahoma", Font.BOLD, 16));
- l2.setForeground(Color.WHITE);
- l2.setBounds(459, 75, 87, 17);
- frame.getContentPane().add(l2);
- JLabel l3 = new JLabel("Anti-Cheat");
- l3.setFont(new Font("Source Sans Pro Black", Font.BOLD | Font.ITALIC, 14));
- l3.setForeground(Color.WHITE);
- l3.setBounds(450, 36, 73, 14);
- frame.getContentPane().add(l3);
- JLabel l4 = new JLabel("created by doron bachar");
- l4.setFont(new Font("Tahoma", Font.BOLD, 14));
- l4.setForeground(Color.WHITE);
- l4.setBounds(360, 287, 175, 17);
- frame.getContentPane().add(l4);
- JLabel l5 = new JLabel("");
- l5.setIcon(new ImageIcon("C:\\Users\\doron\\eclipse-workspace\\dbclient\\img\\4.jpg"));
- l5.setBounds(429, 0, 131, 65);
- frame.getContentPane().add(l5);
- JLabel l6 = new JLabel("");
- l6.setFont(new Font("Tahoma", Font.BOLD, 14));
- l6.setIcon(new ImageIcon("C:\\Users\\doron\\eclipse-workspace\\dbclient\\img\\3.png"));
- l6.setBounds(0, 0, 560, 315);
- frame.getContentPane().add(l6);
- }
- }
- //task check if there length change in screenshot folder
- class S1Task extends TimerTask {
- private File ssFolder;
- private static long filesSz;
- //get the screenshot folder and first length when the program start
- public S1Task(File ssFolder, long filesSz) {
- this.ssFolder = ssFolder;
- this.filesSz = filesSz;
- }
- //instance DBClient for using his static functions
- Gui test = new Gui();
- @Override
- public void run() {
- try {
- //if its the first time in run func filesSz = first length when the program start
- //in other times filesSz = the last length that changed (because its static var) *if the length not changed, filesSz also not
- long tempChanged = test.doEachFile(ssFolder, "length");
- int result = Long.compare(filesSz, tempChanged);
- //if file added
- if(0 > result) {
- filesSz = tempChanged;
- File recentlyCreatedFile = test.sortFolder(ssFolder);
- System.out.println("screenshot added");
- //if file deleted
- } else if(0 < result) {
- filesSz = tempChanged;
- System.out.println("creenshot deleted");
- }
- } catch(Exception e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement