-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
111 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# ???? | ||
# Default | ||
# byObcbO | ||
threads=32 | ||
method=POST | ||
|
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,90 +1,16 @@ | ||
import java.io.File; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.util.Properties; | ||
|
||
public class App { | ||
// 默认值 | ||
static int thnum = 1;// 线程数 | ||
static String method = "POST";// 请求方法 | ||
static String url;// 攻击网址 | ||
static String param;// 攻击参数 | ||
|
||
static boolean success = true; | ||
|
||
public static Properties properties; | ||
|
||
public static void main(String[] args) { | ||
boolean success = false; | ||
try { | ||
file(); | ||
success = file.start(); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
while (success) { | ||
} // todo: gui | ||
} | ||
|
||
private static void file() throws IOException { | ||
String file; | ||
if (System.getProperty("file") == null || System.getProperty("file") == "" | ||
|| System.getProperty("file").trim() == "") { | ||
if (!new File("src/default.properties").exists()) { | ||
generatefile(); | ||
} | ||
file = "default.properties".toString();; | ||
} else | ||
file = System.getProperty("file").toString(); | ||
System.out.println(file); | ||
InputStream inputStream = App.class.getClassLoader().getResourceAsStream(file); | ||
properties = new Properties(); | ||
properties.load(inputStream); | ||
properties.list(System.out); | ||
manage(); | ||
System.out.println("-=-=-=-=- File processing completed"); | ||
if (success) { | ||
post.start(thnum, method, url, param); | ||
} | ||
} | ||
|
||
private static void generatefile() { | ||
properties.setProperty("1", "123"); | ||
} | ||
|
||
private static void manage() { | ||
String temp; | ||
// 线程数 | ||
temp = properties.getProperty("threads"); | ||
if (temp.matches("[0-9]*")) { | ||
thnum = Integer.parseInt(temp); | ||
} else { | ||
success = false; | ||
System.out.println("ERROR: 线程数 你输入的值不是一个正整数"); | ||
} | ||
// 请求方法 | ||
temp = properties.getProperty("method").toUpperCase(); | ||
switch (temp) { | ||
case "GET": | ||
case "HEAD": | ||
case "POST": | ||
case "PUT": | ||
case "DELETE": | ||
case "CONNECT": | ||
case "OPTIONS": | ||
case "TRACE": | ||
case "PATCH": | ||
url = temp; | ||
break; | ||
default: | ||
System.out.println("ERROR: 请求方法 未知的请求方法"); | ||
} | ||
// 攻击网址 | ||
if (properties.getProperty("URL").matches("^(http|https)://([\\w-]+\\.)+[\\w-]+(/[\\w-./?%&=]*)?$")) { | ||
url = properties.getProperty("URL"); | ||
} else { | ||
success = false; | ||
System.out.println("ERROR: 攻击网址 你输入的字符串不是一个网址"); | ||
System.out.println("³É¹¦! ¿ªÊ¼¹¥»÷"); | ||
} | ||
// 参数 | ||
param = properties.getProperty("parameter"); | ||
while (success) {} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# ???? | ||
# Default | ||
# byObcbO | ||
threads=32 | ||
method=POST | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
import java.io.File; | ||
import java.io.FileOutputStream; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.OutputStream; | ||
import java.util.Properties; | ||
|
||
public class file { | ||
// 默认值 | ||
static int thnum = 1;// 线程数 | ||
static String method = "POST";// 请求方法 | ||
static String url;// 攻击网址 | ||
static String param;// 攻击参数 | ||
|
||
static boolean success = true; | ||
|
||
public static Properties properties; | ||
|
||
static boolean start() throws IOException { | ||
String file; | ||
if (System.getProperty("file") == null || System.getProperty("file") == "" | ||
|| System.getProperty("file").trim() == "") { | ||
if (!new File("default.properties").exists()) { | ||
generatefile(); | ||
} | ||
file = "default.properties".toString(); | ||
; | ||
} else | ||
file = System.getProperty("file").toString(); | ||
System.out.println(file); | ||
InputStream inputStream = file.class.getClassLoader().getResourceAsStream(file); | ||
properties = new Properties(); | ||
properties.load(inputStream); | ||
properties.list(System.out); | ||
manage(); | ||
System.out.println("-=-=-=-=- File processing completed"); | ||
if (success) { | ||
post.start(thnum, method, url, param); | ||
} | ||
return success; | ||
} | ||
|
||
private static void generatefile() { | ||
try { | ||
InputStream is = file.class.getResourceAsStream("default.properties"); | ||
File f = new File("default.properties"); | ||
if (!f.exists()) {// 文件不存在时先创建 | ||
f.createNewFile(); | ||
} | ||
OutputStream os = new FileOutputStream(f); | ||
int index = 0; | ||
byte[] bytes = new byte[1024];// 指定每次读取的位数,这里以1024为例 | ||
while ((index = is.read(bytes)) != -1) { | ||
os.write(bytes, 0, index); | ||
} | ||
os.flush(); | ||
os.close(); | ||
is.close(); | ||
|
||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
private static void manage() { | ||
String temp; | ||
// 线程数 | ||
temp = properties.getProperty("threads"); | ||
if (temp.matches("[0-9]*")) { | ||
thnum = Integer.parseInt(temp); | ||
} else { | ||
success = false; | ||
System.out.println("ERROR: 线程数 你输入的值不是一个正整数"); | ||
} | ||
// 请求方法 | ||
temp = properties.getProperty("method").toUpperCase(); | ||
switch (temp) { | ||
case "GET": | ||
case "HEAD": | ||
case "POST": | ||
case "PUT": | ||
case "DELETE": | ||
case "CONNECT": | ||
case "OPTIONS": | ||
case "TRACE": | ||
case "PATCH": | ||
url = temp; | ||
break; | ||
default: | ||
System.out.println("ERROR: 请求方法 未知的请求方法"); | ||
} | ||
// 攻击网址 | ||
if (properties.getProperty("URL").matches("^(http|https)://([\\w-]+\\.)+[\\w-]+(/[\\w-./?%&=]*)?$")) { | ||
url = properties.getProperty("URL"); | ||
} else { | ||
success = false; | ||
System.out.println("ERROR: 攻击网址 你输入的字符串不是一个网址"); | ||
} | ||
// 参数 | ||
param = properties.getProperty("parameter"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters