├── .gitignore
├── .idea
├── .gitignore
├── codeStyles
│ ├── Project.xml
│ └── codeStyleConfig.xml
├── compiler.xml
├── discord.xml
├── jarRepositories.xml
├── misc.xml
└── vcs.xml
├── README.md
├── pom.xml
└── src
└── main
└── java
└── dev
└── halq
└── prchecker
├── Main.java
├── api
├── HalqJar.java
└── ui
│ ├── NativeJFileChooser.java
│ └── PrMainUI.java
└── impl
├── CheckJar.java
└── checks
├── FileEncryptCheck.java
├── UrlCheck.java
└── WebConnectCheck.java
/.gitignore:
--------------------------------------------------------------------------------
1 | # Project exclude paths
2 | /target/
--------------------------------------------------------------------------------
/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 |
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/codeStyles/codeStyleConfig.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/discord.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/.idea/jarRepositories.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # PrChecker
2 |
3 |
4 |
5 | 
6 |
7 | Verify if your java files have malware's!!
8 |
9 |
10 |
11 |
12 |
13 | # How to use
14 | This can check if your java files have malware's or not
15 |
16 | Checks:
17 |
18 | > UrlChecker
19 | WebConnectionChecker
20 | EncryptChecker
21 |
22 | ## Usage
23 |
24 | ```java
25 | java -jar PrChecker.jar
26 | ```
27 |
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | dev.halq.prch
8 | prChecker
9 | 0.0.1
10 |
11 |
12 |
13 |
14 |
15 | org.apache.maven.plugins
16 | maven-compiler-plugin
17 |
18 | 8
19 | 8
20 |
21 |
22 |
23 | org.apache.maven.plugins
24 | maven-jar-plugin
25 |
26 |
27 |
28 | dev.halq.prchecker.Main
29 |
30 |
31 |
32 |
33 |
34 | org.apache.maven.plugins
35 | maven-shade-plugin
36 | 3.2.2
37 |
38 | false
39 |
40 |
41 |
42 | package
43 |
44 | shade
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 | org.projectlombok
56 | lombok
57 | 1.18.12
58 | provided
59 |
60 |
61 | net.sf.jopt-simple
62 | jopt-simple
63 | 5.0.4
64 |
65 |
66 | org.apache.logging.log4j
67 | log4j-core
68 | 2.13.1
69 |
70 |
71 | commons-io
72 | commons-io
73 | 2.11.0
74 |
75 |
76 | org.ow2.asm
77 | asm-tree
78 | 7.3.1
79 |
80 |
81 | org.ow2.asm
82 | asm-commons
83 | 7.3.1
84 |
85 |
86 | com.google.guava
87 | guava
88 | 28.2-jre
89 |
90 |
91 | com.formdev
92 | flatlaf
93 | 2.4
94 |
95 |
96 |
97 |
98 |
--------------------------------------------------------------------------------
/src/main/java/dev/halq/prchecker/Main.java:
--------------------------------------------------------------------------------
1 | package dev.halq.prchecker;
2 |
3 | import dev.halq.prchecker.api.ui.PrMainUI;
4 | import dev.halq.prchecker.impl.CheckJar;
5 |
6 | import java.io.File;
7 |
8 | /**
9 | * @author Halq
10 | * @since 05/10/22
11 | */
12 |
13 | public class Main {
14 |
15 | public static String version = "0.0.1";
16 |
17 | public static void main(String[] args) {
18 | PrMainUI.mainUI();
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/java/dev/halq/prchecker/api/HalqJar.java:
--------------------------------------------------------------------------------
1 | package dev.halq.prchecker.api;
2 |
3 | import org.apache.commons.io.IOUtils;
4 | import org.objectweb.asm.ClassReader;
5 | import org.objectweb.asm.tree.ClassNode;
6 |
7 | import java.io.File;
8 | import java.io.InputStream;
9 | import java.util.*;
10 | import java.util.jar.JarEntry;
11 | import java.util.jar.JarFile;
12 |
13 | /**
14 | * @author Halq
15 | * @since 27/10/2022 at 21:42
16 | */
17 |
18 | public class HalqJar {
19 |
20 | public static final Map files = new HashMap<>();
21 | public static final List classes = new ArrayList<>();
22 |
23 | public static void loadJar(File file) {
24 | try (JarFile jarFile = new JarFile(file)) {
25 | final Enumeration entries = jarFile.entries();
26 | while (entries.hasMoreElements()) {
27 | final JarEntry jarEntry = entries.nextElement();
28 | try (InputStream inputStream = jarFile.getInputStream(jarEntry)) {
29 | final byte[] bytes = IOUtils.toByteArray(inputStream);
30 | if (!jarEntry.getName().endsWith(".class")) {
31 | files.put(jarEntry.getName(), bytes);
32 | } else {
33 | final ClassNode classNode = new ClassNode();
34 | new ClassReader(bytes).accept(classNode, 0);
35 | classes.add(classNode);
36 | }
37 | }
38 | }
39 | } catch (Exception e) {
40 | e.printStackTrace();
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/main/java/dev/halq/prchecker/api/ui/NativeJFileChooser.java:
--------------------------------------------------------------------------------
1 | package dev.halq.prchecker.api.ui;
2 |
3 |
4 | import javafx.application.Platform;
5 | import javafx.embed.swing.JFXPanel;
6 | import javafx.stage.DirectoryChooser;
7 | import javafx.stage.FileChooser;
8 |
9 | import javax.swing.*;
10 | import javax.swing.filechooser.FileFilter;
11 | import javax.swing.filechooser.FileNameExtensionFilter;
12 | import javax.swing.filechooser.FileSystemView;
13 | import java.awt.*;
14 | import java.io.File;
15 | import java.util.ArrayList;
16 | import java.util.Arrays;
17 | import java.util.Iterator;
18 | import java.util.List;
19 | import java.util.concurrent.CountDownLatch;
20 |
21 | /**
22 | * This is a drop-in replacement for Swing's file chooser. Instead of displaying
23 | * Swing's file chooser, it makes use of JavaFX's file chooser. JavaFX uses the
24 | * OS's native file chooser. Technically, this class is a memory hog, but its
25 | * use is convenient. Furthermore, if JavaFX is not available, the default file
26 | * chooser will be displayed instead. Of course, this class will not compile if
27 | * you don't have an JDK 8 or higher that has JavaFX support. Since this class
28 | * will have to call the constructor of JFileChooser, it won't increase the
29 | * performance of the file chooser; if anything, it might further decrease it.
30 | * Please note that some methods have not been overwritten and may not have any
31 | * impact on the file chooser. Sometimes, the new JavaFX file chooser does not
32 | * provide certain functionality. One feature that is not supported is the
33 | * selection of files AND directories. If trying to set this using
34 | * setFileSelectionMode(), still only files will be selectable.
35 | *
36 | * @author Steffen Flor
37 | * @version 1.6.3
38 | */
39 | public class NativeJFileChooser extends JFileChooser
40 |
41 |
42 | {
43 |
44 | public static final boolean FX_AVAILABLE;
45 |
46 | static
47 | {
48 | boolean isFx;
49 | try
50 | {
51 | Class.forName( "javafx.stage.FileChooser" );
52 | isFx = true;
53 | // Initializes JavaFX environment
54 | JFXPanel jfxPanel = new JFXPanel();
55 | } catch ( ClassNotFoundException e )
56 | {
57 | isFx = false;
58 | }
59 |
60 | FX_AVAILABLE = isFx;
61 | }
62 |
63 | private List< File > currentFiles;
64 | private FileChooser fileChooser;
65 | private File currentFile;
66 | private DirectoryChooser directoryChooser;
67 |
68 | public NativeJFileChooser()
69 | {
70 | initFxFileChooser( null );
71 | }
72 |
73 | public NativeJFileChooser( String currentDirectoryPath )
74 | {
75 | super( currentDirectoryPath );
76 | initFxFileChooser( new File( currentDirectoryPath ) );
77 | }
78 |
79 | public NativeJFileChooser( File currentDirectory )
80 | {
81 | super( currentDirectory );
82 | initFxFileChooser( currentDirectory );
83 | }
84 |
85 | public NativeJFileChooser( FileSystemView fsv )
86 | {
87 | super( fsv );
88 | initFxFileChooser( fsv.getDefaultDirectory() );
89 | }
90 |
91 | public NativeJFileChooser( File currentDirectory, FileSystemView fsv )
92 | {
93 | super( currentDirectory, fsv );
94 | initFxFileChooser( currentDirectory );
95 | }
96 |
97 | public NativeJFileChooser( String currentDirectoryPath, FileSystemView fsv )
98 | {
99 | super( currentDirectoryPath, fsv );
100 | initFxFileChooser( new File( currentDirectoryPath ) );
101 | }
102 |
103 |
104 | @Override
105 | public int showOpenDialog( final Component parent ) throws HeadlessException
106 | {
107 | if ( !FX_AVAILABLE )
108 | {
109 | return super.showOpenDialog( parent );
110 | }
111 |
112 | final CountDownLatch latch = new CountDownLatch( 1 );
113 | Platform.runLater( new Runnable()
114 | {
115 | @Override
116 | public void run()
117 | {
118 |
119 | if ( parent != null )
120 | {
121 | parent.setEnabled( false );
122 | }
123 |
124 | if ( isDirectorySelectionEnabled() )
125 | {
126 | currentFile = directoryChooser.showDialog( null );
127 | } else
128 | {
129 | if ( isMultiSelectionEnabled() )
130 | {
131 | currentFiles = fileChooser.showOpenMultipleDialog( null );
132 | } else
133 | {
134 | currentFile = fileChooser.showOpenDialog( null );
135 | }
136 | }
137 | latch.countDown();
138 | }
139 |
140 | } );
141 | try
142 | {
143 | latch.await();
144 | } catch ( InterruptedException ex )
145 | {
146 | throw new RuntimeException( ex );
147 | } finally
148 | {
149 | if ( parent != null )
150 | {
151 | parent.setEnabled( true );
152 | }
153 | }
154 |
155 | if ( isMultiSelectionEnabled() )
156 | {
157 | if ( currentFiles != null )
158 | {
159 | return JFileChooser.APPROVE_OPTION;
160 | } else
161 | {
162 | return JFileChooser.CANCEL_OPTION;
163 | }
164 | } else
165 | {
166 | if ( currentFile != null )
167 | {
168 | return JFileChooser.APPROVE_OPTION;
169 | } else
170 | {
171 | return JFileChooser.CANCEL_OPTION;
172 | }
173 | }
174 |
175 | }
176 |
177 | @Override
178 | public int showSaveDialog( final Component parent ) throws HeadlessException
179 | {
180 | if ( !FX_AVAILABLE )
181 | {
182 | return super.showSaveDialog( parent );
183 | }
184 |
185 | final CountDownLatch latch = new CountDownLatch( 1 );
186 |
187 | Platform.runLater( new Runnable()
188 | {
189 | @Override
190 | public void run()
191 | {
192 |
193 | if ( parent != null )
194 | {
195 | parent.setEnabled( false );
196 | }
197 |
198 | if ( isDirectorySelectionEnabled() )
199 | {
200 | currentFile = directoryChooser.showDialog( null );
201 | } else
202 | {
203 | currentFile = fileChooser.showSaveDialog( null );
204 | }
205 | latch.countDown();
206 | }
207 |
208 | } );
209 | try
210 | {
211 | latch.await();
212 | } catch ( InterruptedException ex )
213 | {
214 | throw new RuntimeException( ex );
215 | } finally
216 | {
217 | if ( parent != null )
218 | {
219 | parent.setEnabled( true );
220 | }
221 | }
222 |
223 | if ( currentFile != null )
224 | {
225 | return JFileChooser.APPROVE_OPTION;
226 | } else
227 | {
228 | return JFileChooser.CANCEL_OPTION;
229 | }
230 | }
231 |
232 | @Override
233 | public int showDialog( Component parent, String approveButtonText )
234 | {
235 | if ( !FX_AVAILABLE )
236 | {
237 | return super.showDialog( parent, approveButtonText );
238 | }
239 | return showOpenDialog( parent );
240 | }
241 |
242 | @Override
243 | public File[] getSelectedFiles()
244 | {
245 | if ( !FX_AVAILABLE )
246 | {
247 | return super.getSelectedFiles();
248 | }
249 | if ( currentFiles == null )
250 | {
251 | return null;
252 | }
253 | return currentFiles.toArray( new File[ currentFiles.size() ] );
254 | }
255 |
256 | @Override
257 | public void setSelectedFiles( File[] selectedFiles )
258 | {
259 | if ( !FX_AVAILABLE )
260 | {
261 | super.setSelectedFiles( selectedFiles );
262 | return;
263 | }
264 | if ( selectedFiles == null || selectedFiles.length == 0 )
265 | {
266 | currentFiles = null;
267 | } else
268 | {
269 | setSelectedFile( selectedFiles[ 0 ] );
270 | currentFiles = new ArrayList<>( Arrays.asList( selectedFiles ) );
271 | }
272 | }
273 |
274 | @Override
275 | public File getSelectedFile()
276 | {
277 | if ( !FX_AVAILABLE )
278 | {
279 | return super.getSelectedFile();
280 | }
281 | return currentFile;
282 | }
283 |
284 | @Override
285 | public void setSelectedFile( File file )
286 | {
287 | if ( !FX_AVAILABLE )
288 | {
289 | super.setSelectedFile( file );
290 | return;
291 | }
292 | currentFile = file;
293 | if ( file != null )
294 | {
295 | if ( file.isDirectory() )
296 | {
297 | fileChooser.setInitialDirectory( file.getAbsoluteFile() );
298 |
299 | if ( directoryChooser != null )
300 | {
301 | directoryChooser.setInitialDirectory( file.getAbsoluteFile() );
302 | }
303 | } else if ( file.isFile() )
304 | {
305 | fileChooser.setInitialDirectory( file.getParentFile() );
306 | fileChooser.setInitialFileName( file.getName() );
307 |
308 | if ( directoryChooser != null )
309 | {
310 | directoryChooser.setInitialDirectory( file.getParentFile() );
311 | }
312 | }
313 |
314 | }
315 | }
316 |
317 | @Override
318 | public void setFileSelectionMode( int mode )
319 | {
320 | super.setFileSelectionMode( mode );
321 | if ( !FX_AVAILABLE )
322 | {
323 | return;
324 | }
325 | if ( mode == DIRECTORIES_ONLY )
326 | {
327 | if ( directoryChooser == null )
328 | {
329 | directoryChooser = new DirectoryChooser();
330 | }
331 | // Set file again, so directory chooser will be affected by it
332 | setSelectedFile( currentFile );
333 | setDialogTitle( getDialogTitle() );
334 | }
335 | }
336 |
337 | @Override
338 | public String getDialogTitle()
339 | {
340 | if ( !FX_AVAILABLE )
341 | {
342 | return super.getDialogTitle();
343 | }
344 | return fileChooser.getTitle();
345 | }
346 |
347 | @Override
348 | public void setDialogTitle( String dialogTitle )
349 | {
350 | if ( !FX_AVAILABLE )
351 | {
352 | super.setDialogTitle( dialogTitle );
353 | return;
354 | }
355 | fileChooser.setTitle( dialogTitle );
356 | if ( directoryChooser != null )
357 | {
358 | directoryChooser.setTitle( dialogTitle );
359 | }
360 | }
361 |
362 | @Override
363 | public void changeToParentDirectory()
364 | {
365 | if ( !FX_AVAILABLE )
366 | {
367 | super.changeToParentDirectory();
368 | return;
369 | }
370 | File parentDir = fileChooser.getInitialDirectory().getParentFile();
371 | if ( parentDir.isDirectory() )
372 | {
373 | fileChooser.setInitialDirectory( parentDir );
374 | if ( directoryChooser != null )
375 | {
376 | directoryChooser.setInitialDirectory( parentDir );
377 | }
378 | }
379 | }
380 |
381 | @Override
382 | public void addChoosableFileFilter( FileFilter filter )
383 | {
384 | super.addChoosableFileFilter( filter );
385 | if ( !FX_AVAILABLE || filter == null )
386 | {
387 | return;
388 | }
389 | if ( filter.getClass().equals( FileNameExtensionFilter.class ) )
390 | {
391 | FileNameExtensionFilter f = ( FileNameExtensionFilter ) filter;
392 |
393 | List< String > ext = new ArrayList<>();
394 | for ( String extension : f.getExtensions() )
395 | {
396 | ext.add( extension.replaceAll( "^\\*?\\.?(.*)$", "*.$1" ) );
397 | }
398 | fileChooser.getExtensionFilters().add( new FileChooser.ExtensionFilter( f.getDescription(), ext ) );
399 | }
400 | }
401 |
402 | @Override
403 | public void setAcceptAllFileFilterUsed( boolean bool )
404 | {
405 | boolean differs = isAcceptAllFileFilterUsed() ^ bool;
406 | super.setAcceptAllFileFilterUsed( bool );
407 | if ( !FX_AVAILABLE )
408 | {
409 | return;
410 | }
411 | if ( !differs )
412 | {
413 | return;
414 | }
415 | if ( bool )
416 | {
417 | fileChooser.getExtensionFilters().add( new FileChooser.ExtensionFilter( "All files", "*.*" ) );
418 | } else
419 | {
420 | for ( Iterator< FileChooser.ExtensionFilter > it = fileChooser.getExtensionFilters()
421 | .iterator() ; it.hasNext() ; )
422 | {
423 | FileChooser.ExtensionFilter filter = it.next();
424 | if ( filter.getExtensions().size() == 1 && filter.getExtensions().contains( "*.*" ) )
425 | {
426 | it.remove();
427 | }
428 | }
429 | }
430 |
431 | }
432 |
433 | private void initFxFileChooser( File currentFile )
434 | {
435 |
436 | if ( FX_AVAILABLE )
437 | {
438 | fileChooser = new FileChooser();
439 | this.currentFile = currentFile;
440 | setSelectedFile( currentFile );
441 | }
442 | }
443 |
444 | }
--------------------------------------------------------------------------------
/src/main/java/dev/halq/prchecker/api/ui/PrMainUI.java:
--------------------------------------------------------------------------------
1 | package dev.halq.prchecker.api.ui;
2 |
3 | import com.formdev.flatlaf.FlatDarculaLaf;
4 | import dev.halq.prchecker.Main;
5 | import dev.halq.prchecker.impl.CheckJar;
6 |
7 | import javax.swing.*;
8 | import java.awt.*;
9 | import java.io.File;
10 | import java.io.IOException;
11 | import java.io.OutputStream;
12 | import java.io.PrintStream;
13 |
14 | /**
15 | * @author Halq
16 | * @since 27/10/2022 at 22:32
17 | */
18 |
19 | public class PrMainUI {
20 |
21 | static JFrame frame;
22 | static JPanel mainP, p1, p2, p3, p4, p5;
23 | static JLabel fileabel, versionLabel;
24 | static JButton checker, fileChooser;
25 | static JCheckBox encrypt, url, webConnect;
26 | static JTextField file;
27 | static Font font2 = new Font("Ariel", Font.BOLD, 9);
28 | static JTextArea textArea;
29 |
30 |
31 | public static void mainUI(){
32 | FlatDarculaLaf.setup();
33 |
34 | frame = new JFrame("PRChecker");
35 | frame.setSize(500, 500);
36 | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
37 | frame.setVisible(true);
38 |
39 | mainP = new JPanel();
40 |
41 | p1 = new JPanel();
42 | p2 = new JPanel();
43 | p3 = new JPanel();
44 | p4 = new JPanel();
45 | p5 = new JPanel();
46 |
47 | fileabel = new JLabel("File: ");
48 | fileChooser = new JButton("...");
49 | file = new JTextField(30);
50 |
51 | p1.add(fileabel);
52 | p1.add(file);
53 | p1.add(fileChooser);
54 | fileChooser.addActionListener(e -> {
55 | JFileChooser chooser = new JFileChooser();
56 | chooser.showOpenDialog(null);
57 | File f = chooser.getSelectedFile();
58 | file.setText(f.getAbsolutePath());
59 | });
60 |
61 | p1.setBounds(0, 20, 500, 50);
62 |
63 | url = new JCheckBox("URLChecker ");
64 | encrypt = new JCheckBox("EncryptChecker ");
65 | webConnect = new JCheckBox("WebConnectChecker ");
66 | p2.add(url);
67 | p2.add(encrypt);
68 | p2.add(webConnect);
69 | p2.setBounds(140, 100, 500, 100);
70 |
71 | textArea = new JTextArea(20, 40);
72 | textArea.setEditable(false);
73 | textArea.setFont(font2);
74 |
75 | OutputStream out = new OutputStream() {
76 | @Override
77 | public void write(int b) throws IOException {
78 | textArea.append(String.valueOf((char) b));
79 | }
80 | };
81 |
82 | System.setOut(new PrintStream(out));
83 | System.setErr(new PrintStream(out));
84 |
85 | p3.add(textArea);
86 | p3.setBounds(-50, 186, 900, 160);
87 |
88 | JScrollPane scroll = new JScrollPane (textArea);
89 | scroll.setVerticalScrollBarPolicy ( ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS );
90 | scroll.setBounds(90, 170, 630, 230);
91 |
92 | frame.add(scroll);
93 | frame.add(p3);
94 |
95 | checker = new JButton("Check");
96 | p4.add(checker);
97 | checker.addActionListener(e -> {
98 | if(url.isSelected()){
99 | CheckJar.checkUrl(new File(file.getText()));
100 | }
101 | if(encrypt.isSelected()){
102 | CheckJar.checkEncrypt(new File(file.getText()));
103 | }
104 | if(webConnect.isSelected()){
105 | CheckJar.checkConnection(new File(file.getText()));
106 | }
107 | });
108 |
109 | p4.setBounds(340, 400, 100, 100);
110 |
111 | versionLabel = new JLabel("Version: " + Main.version);
112 | p5.add(versionLabel);
113 | p5.setBounds(0, 410, 100, 100);
114 |
115 | frame.add(p1);
116 | frame.add(p2);
117 | frame.add(p4);
118 | frame.add(p5);
119 |
120 | mainP.setPreferredSize(new Dimension(800, 450));
121 | frame.add(mainP, BorderLayout.CENTER);
122 | frame.setLocation(150, 100);
123 | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
124 | frame.setResizable(false);
125 | frame.pack();
126 |
127 | frame.setVisible(true);
128 | }
129 | }
130 |
--------------------------------------------------------------------------------
/src/main/java/dev/halq/prchecker/impl/CheckJar.java:
--------------------------------------------------------------------------------
1 | package dev.halq.prchecker.impl;
2 |
3 | import dev.halq.prchecker.api.HalqJar;
4 | import dev.halq.prchecker.impl.checks.FileEncryptCheck;
5 | import dev.halq.prchecker.impl.checks.UrlCheck;
6 | import dev.halq.prchecker.impl.checks.WebConnectCheck;
7 |
8 | import java.io.File;
9 |
10 | /**
11 | * @author Halq
12 | * @since 27/10/2022 at 21:54
13 | */
14 |
15 | public class CheckJar {
16 |
17 | public static void checkUrl(File file){
18 | HalqJar.loadJar(file);
19 | UrlCheck.verifyURL(HalqJar.classes);
20 | }
21 |
22 | public static void checkEncrypt(File file) {
23 | HalqJar.loadJar(file);
24 | FileEncryptCheck.verifyFileEncrypt(HalqJar.classes);
25 | }
26 |
27 | public static void checkConnection(File file) {
28 | HalqJar.loadJar(file);
29 | WebConnectCheck.verifyWebConnect(HalqJar.classes);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/dev/halq/prchecker/impl/checks/FileEncryptCheck.java:
--------------------------------------------------------------------------------
1 | package dev.halq.prchecker.impl.checks;
2 |
3 | import org.objectweb.asm.tree.AbstractInsnNode;
4 | import org.objectweb.asm.tree.ClassNode;
5 | import org.objectweb.asm.tree.MethodInsnNode;
6 | import org.objectweb.asm.tree.MethodNode;
7 |
8 | import java.util.List;
9 |
10 | /**
11 | * @author Halq
12 | * @since 27/10/2022 at 21:59
13 | */
14 |
15 | public class FileEncryptCheck {
16 |
17 | public static void verifyFileEncrypt(List node) {
18 | for (ClassNode classNode : node) {
19 | for (MethodNode methodNode : classNode.methods) {
20 | for (AbstractInsnNode abstractInsnNode : methodNode.instructions.toArray()) {
21 | if (abstractInsnNode instanceof MethodInsnNode) {
22 | MethodInsnNode methodInsnNode = (MethodInsnNode) abstractInsnNode;
23 | if (methodInsnNode.owner.equals("javax/crypto/Cipher")) {
24 | System.out.println("Found File Encrypt: " + "class: " + classNode.name + "methodInsn: " + methodInsnNode.owner + "." + methodInsnNode.name);
25 | }
26 | }
27 | }
28 | }
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/src/main/java/dev/halq/prchecker/impl/checks/UrlCheck.java:
--------------------------------------------------------------------------------
1 | package dev.halq.prchecker.impl.checks;
2 |
3 | import org.objectweb.asm.tree.AbstractInsnNode;
4 | import org.objectweb.asm.tree.ClassNode;
5 | import org.objectweb.asm.tree.LdcInsnNode;
6 | import org.objectweb.asm.tree.MethodNode;
7 |
8 | import java.util.List;
9 |
10 | /**
11 | * @author Halq
12 | * @since 27/10/2022 at 21:51
13 | */
14 |
15 | public class UrlCheck {
16 |
17 | public static void verifyURL(List node){
18 | for (ClassNode classNode : node) {
19 | for(MethodNode methodNode : classNode.methods){
20 | for(AbstractInsnNode abstractInsnNode : methodNode.instructions.toArray()){
21 | if(abstractInsnNode instanceof LdcInsnNode){
22 | LdcInsnNode ldcInsnNode = (LdcInsnNode) abstractInsnNode;
23 | if(ldcInsnNode.cst instanceof String){
24 | String string = (String) ldcInsnNode.cst;
25 | if(string.contains("http://") || string.contains("https://")){
26 | System.out.println("Found URL: " + "class: " + classNode.name );
27 | }
28 | }
29 | }
30 | }
31 | }
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/dev/halq/prchecker/impl/checks/WebConnectCheck.java:
--------------------------------------------------------------------------------
1 | package dev.halq.prchecker.impl.checks;
2 |
3 | import org.objectweb.asm.tree.AbstractInsnNode;
4 | import org.objectweb.asm.tree.ClassNode;
5 | import org.objectweb.asm.tree.MethodInsnNode;
6 | import org.objectweb.asm.tree.MethodNode;
7 |
8 | import java.util.List;
9 |
10 | /**
11 | * @author Halq
12 | * @since 27/10/2022 at 22:19
13 | */
14 |
15 | public class WebConnectCheck {
16 |
17 | public static void verifyWebConnect(List node) {
18 | for (ClassNode classNode : node) {
19 | for (MethodNode methodNode : classNode.methods) {
20 | for (AbstractInsnNode abstractInsnNode : methodNode.instructions.toArray()) {
21 | if (abstractInsnNode instanceof MethodInsnNode) {
22 | MethodInsnNode methodInsnNode = (MethodInsnNode) abstractInsnNode;
23 | if (methodInsnNode.owner.equals("java/net/URLConnection")) {
24 | System.out.println("Found Web Connect: " + "class: " + classNode.name);
25 | }
26 | }
27 | }
28 | }
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------