Repository navigation
Expand file tree
/
Copy pathDisableUpxD.java
More file actions
executable file
·59 lines (45 loc) · 1.61 KB
/
Copy pathDisableUpxD.java
File metadata and controls
executable file
·59 lines (45 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package disable_upx_d;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
public class DisableUpxD
{
public static void main(String[] args)
{
Path p = FileSystems.getDefault().getPath("", "hello_world_packed.exe");
System.out.println("PATH: " + p.toAbsolutePath().toString());
try
{
byte [] fileData = Files.readAllBytes(p);
boolean patched = false;
System.out.println("file size: " + fileData.length);
for(int i=0; i < fileData.length; ++i)
{
System.out.println(Integer.toHexString(fileData[i]));
if((fileData[i] == 0x55) && (fileData[i+1] == 0x50) && (fileData[i+2] == 0x58) && (fileData[i+3] == 0x30))
{
fileData[i] = 0x41; // Change U 0x55 to A 0x41
break;
}
}
if(patched)
{
FileOutputStream fos = new FileOutputStream("hello_world_packed_modified.exe");
fos.write(fileData);
fos.close();
System.out.println("Your file is patched now");
}
else
{
System.out.println("Your file was not patched");
}
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}