JAVA开发--U盘EXE恢复工具

时间:2023-03-09 14:45:38
JAVA开发--U盘EXE恢复工具

原理比较简单,在学校机房U盘总被感染,写一个工具来方便用

 package com.udiskrecover;

 import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException; import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.text.AbstractDocument.Content; /*
############################################################
# #
# 【名称】 : U盘EXE恢复工具 #
# 【作者】 : Sevck(一个写代码很帅的男人) #
# 【团队】 : 网络尖刀 #
# 【主页】 : http://sevck.lofter.com #
# 【日期】 : 2015-10-15 #
# 【功能】 : 将磁盘上病毒引起的感染EXE通过DOS恢复 #
# #
############################################################
#   ┏┓ ┏┓
#┏┛┻━━━┛┻┓
#┃ ┃
#┃ ━ ┃
#┃ ┳┛ ┗┳ ┃
#┃ ┃
#┃ ``` ┻ ```┃
#┃ ┃
#┗━┓ ┏━┛
#####┃ ┃Code is far away from bug with the animal protecting.
#####┃ ┃神兽护佑,代码无Bug.
#####┃ ┗━━━━━┓
#####┃ ┣┓
#####┃ ┏┛
#####┗┓┓┏━┳┓┏┛
#######┃┫┫ ┃┫┫
#######┗┻┛ ┗┻┛
############################################################
*/
public class UDiskRecover extends JFrame { JLabel label;
JTextField text;
JButton submit;
String reg = "[a-zA-Z]{1}"; public UDiskRecover() {
init();
} public void init() {
Container cp = this.getContentPane();
label = new JLabel("请输入要恢复的磁盘:");
text = new JTextField(10);
submit = new JButton("确定");
cp.add(label);
cp.add(text);
cp.add(submit); this.setSize(300, 200);
this.setVisible(true);
this.setDefaultCloseOperation(3);
//this.setLocationRelativeTo(null);
this.setTitle("U盘EXE恢复工具--By:Sevck");
this.setLayout(new FlowLayout(1, 20, 30));
this.setResizable(false);
submit.addActionListener(new ActionListener() { @Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub String content = text.getText();
boolean z = content.matches(reg);
Process process = null;
if (z) {
String cmd = "cmd.exe /c attrib -s -h -r " + content
+ ":\\\\* /s /d";
// String cmd="cmd.exe /c move d:\\1.txt e:\\";
// String cmd="cmd.exe /c move d:\\1.txt e:\\";
// System.out.println(newcon);
// System.out.println(cmd);
try {
process = Runtime.getRuntime().exec(cmd);
System.out.println(process.toString());
JOptionPane.showMessageDialog(null, "文件恢复成功!");
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
JOptionPane.showMessageDialog(null, "文件恢复失败!");
}
} else {
JOptionPane.showMessageDialog(null,
"请输入正确的盘符!\r\n提示:a-z||A-Z,不需要写“:”.");
}
}
}); } public static void main(String[] args) {
new UDiskRecover();
}
}