-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHwidCopier.java
More file actions
125 lines (109 loc) · 4.9 KB
/
HwidCopier.java
File metadata and controls
125 lines (109 loc) · 4.9 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
import javax.swing.*;
import java.awt.*;
import java.awt.datatransfer.StringSelection;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class HwidCopier {
public static void main(String[] args) {
SwingUtilities.invokeLater(HwidCopier::createAndShowGUI);
}
private static void createAndShowGUI() {
JFrame frame = new JFrame("HWID");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(500, 250);
frame.setResizable(false);
JPanel mainPanel = new JPanel() {
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2d = (Graphics2D) g;
int w = getWidth();
int h = getHeight();
// Gradient background
Color startColor = new Color(30, 30, 30);
Color endColor = new Color(60, 60, 60);
GradientPaint gp = new GradientPaint(0, 0, startColor, w, h, endColor);
g2d.setPaint(gp);
g2d.fillRect(0, 0, w, h);
// Adds a subtle highlight at the top for depth
g2d.setColor(new Color(80, 80, 80, 100));
g2d.fillRect(0, 0, w, 20);
}
};
mainPanel.setLayout(new BorderLayout());
String hwid = getSHA256Hash();
JTextArea hwidLabel = new JTextArea(hwid);
hwidLabel.setLineWrap(true);
hwidLabel.setWrapStyleWord(true);
hwidLabel.setEditable(false);
hwidLabel.setBackground(new Color(45, 45, 45));
hwidLabel.setForeground(Color.WHITE);
hwidLabel.setFont(new Font("Consolas", Font.PLAIN, 14));
hwidLabel.setBorder(BorderFactory.createEmptyBorder(15, 15, 15, 15));
// Scroll pane for the HWID if it's too long
JScrollPane scrollPane = new JScrollPane(hwidLabel);
scrollPane.setBorder(BorderFactory.createEmptyBorder());
scrollPane.getViewport().setOpaque(false);
scrollPane.setOpaque(false);
JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
buttonPanel.setOpaque(false);
JButton copyButton = new JButton("Copy HWID");
copyButton.setFont(new Font("Arial", Font.BOLD, 16));
copyButton.setBackground(new Color(70, 130, 180));
copyButton.setForeground(Color.WHITE);
copyButton.setFocusPainted(false);
copyButton.setBorderPainted(false);
copyButton.setCursor(new Cursor(Cursor.HAND_CURSOR));
copyButton.addActionListener(e -> {
StringSelection selection = new StringSelection(hwid);
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(selection, null);
JOptionPane.showMessageDialog(frame, "HWID copied to clipboard!", "Success", JOptionPane.INFORMATION_MESSAGE);
});
// Hover effect for the button
copyButton.addMouseListener(new MouseAdapter() {
@Override
public void mouseEntered(MouseEvent e) {
copyButton.setBackground(new Color(80, 140, 190));
}
@Override
public void mouseExited(MouseEvent e) {
copyButton.setBackground(new Color(70, 130, 180));
}
});
buttonPanel.add(copyButton);
mainPanel.add(scrollPane, BorderLayout.CENTER);
mainPanel.add(buttonPanel, BorderLayout.SOUTH);
frame.add(mainPanel);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
private static String getSHA256Hash() {
try {
String rawHWID = System.getProperty("os.name") +
System.getProperty("os.version") +
System.getProperty("os.arch") +
System.getProperty("user.name") +
System.getenv("SystemRoot") +
System.getenv("HOMEDRIVE") +
System.getenv("PROCESSOR_LEVEL") +
System.getenv("PROCESSOR_REVISION") +
System.getenv("PROCESSOR_IDENTIFIER") +
System.getenv("PROCESSOR_ARCHITECTURE") +
System.getenv("PROCESSOR_ARCHITEW6432") +
System.getenv("NUMBER_OF_PROCESSORS");
MessageDigest sha256Digest = MessageDigest.getInstance("SHA-256");
byte[] hashBytes = sha256Digest.digest(rawHWID.getBytes());
StringBuilder hexString = new StringBuilder();
for (byte b : hashBytes) {
String hex = Integer.toHexString(0xff & b);
if (hex.length() == 1) hexString.append('0');
hexString.append(hex);
}
return hexString.toString().toUpperCase();
} catch (NoSuchAlgorithmException e) {
return "Error: SHA-256 algorithm not found!";
}
}
}