Skip to content

Commit

Permalink
StringUtils.isEmpty()
Browse files Browse the repository at this point in the history
  • Loading branch information
bit4woo committed Apr 9, 2024
1 parent 1529901 commit 600dab6
Show file tree
Hide file tree
Showing 25 changed files with 96 additions and 64 deletions.
6 changes: 3 additions & 3 deletions src/ASN/ASNEntry.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package ASN;

import java.util.List;

import inet.ipaddr.AddressStringException;
import inet.ipaddr.IPAddress;
import inet.ipaddr.IPAddressSeqRange;
import inet.ipaddr.IPAddressString;
import utils.IPAddressUtils;
import org.apache.commons.lang3.StringUtils;
import java.util.List;

/**
*存储
Expand Down Expand Up @@ -122,7 +122,7 @@ public void setAlias(String alias) {
* get开头的函数会被序列化过程调用
*/
public String fetchASNDescription() {
if (!getAlias().equals("")){
if (StringUtils.isNotEmpty(getAlias())){
return getAlias();
}else{
return getAsname_long();
Expand Down
4 changes: 3 additions & 1 deletion src/GUI/JTextFieldHintListener.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package GUI;

import org.apache.commons.lang3.StringUtils;

import java.awt.Color;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
Expand Down Expand Up @@ -35,7 +37,7 @@ public void focusGained(FocusEvent e) {
public void focusLost(FocusEvent e) {
//失去焦点时,没有输入内容,显示提示内容
String temp = textField.getText();
if(temp.equals("")) {
if(StringUtils.isEmpty(temp)) {
textField.setForeground(Color.GRAY);
textField.setText(hintText);
}
Expand Down
8 changes: 5 additions & 3 deletions src/InternetSearch/APISearchAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import javax.swing.SwingWorker;
import javax.swing.table.AbstractTableModel;

import org.apache.commons.lang3.StringUtils;

import InternetSearch.Client.FoFaClient;
import InternetSearch.Client.HunterClient;
import InternetSearch.Client.QuakeClient;
Expand Down Expand Up @@ -113,7 +115,7 @@ protected Map doInBackground() throws Exception {
searchContent = ((TargetTableModel) lineModel).getValueForSearch(row, columnIndex, engine);
}

if (searchContent == null || searchContent.equals("")) {
if (StringUtils.isEmpty(searchContent)) {
stderr.print("nothing to search...");
return null;
}
Expand Down Expand Up @@ -157,7 +159,7 @@ protected void done() {

public static List<SearchResultEntry> DoSearch(String searchContent, String engine) {
List<SearchResultEntry> entries = new ArrayList<>();
if (searchContent == null || searchContent.equals("")){
if (StringUtils.isEmpty(searchContent)){
return entries;
}
if (engine.equals(SearchEngine.FOFA)) {
Expand All @@ -184,7 +186,7 @@ public static List<SearchResultEntry> DoSearch(String searchContent, String engi
}

public static String capitalizeFirstLetter(String str) {
if (str == null || str.isEmpty()) {
if (StringUtils.isEmpty(str)) {
return str;
}
return str.substring(0, 1).toUpperCase() + str.toLowerCase().substring(1);
Expand Down
15 changes: 14 additions & 1 deletion src/InternetSearch/Client/BaseClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;

import com.google.common.base.Strings;

import InternetSearch.HttpClientOfBurp;
import InternetSearch.SearchResultEntry;
import burp.BurpExtender;
Expand Down Expand Up @@ -95,11 +100,19 @@ public void printDebugInfo() {
}else {
content = resp_body;
}

String reqRaw;
if (this.raw == null) {
reqRaw = this.raw+"";
}else {
reqRaw = new String(this.raw);
}
stderr.println("====================");
stderr.println(this.url);
stderr.println(this.raw);
stderr.println(reqRaw);
stderr.println(content);
stderr.println("====================");

}

public List<SearchResultEntry> SearchToGetEntry(String searchContent){
Expand Down
4 changes: 2 additions & 2 deletions src/InternetSearch/Client/FoFaClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
import java.util.Base64;
import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;

import InternetSearch.SearchEngine;
import InternetSearch.SearchResultEntry;
import Tools.JSONHandler;
import burp.BurpExtender;
import config.ConfigManager;
import config.ConfigName;

Expand Down Expand Up @@ -73,7 +73,7 @@ public boolean hasNextPage(String respbody,int currentPage) {
public String buildSearchUrl(String searchContent, int page) {
String email = ConfigManager.getStringConfigByKey(ConfigName.FofaEmail);
String key = ConfigManager.getStringConfigByKey(ConfigName.FofaKey);
if (email.equals("") || key.equals("")) {
if (StringUtils.isEmpty(key)) {
stderr.println("fofa.info emaill or key not configurated!");
return null;
}
Expand Down
4 changes: 2 additions & 2 deletions src/InternetSearch/Client/ShodanClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;

import InternetSearch.SearchEngine;
import InternetSearch.SearchResultEntry;
import Tools.JSONHandler;
import burp.BurpExtender;
import config.ConfigManager;
import config.ConfigName;

Expand Down Expand Up @@ -77,7 +77,7 @@ public boolean hasNextPage(String respbody,int currentPage) {
@Override
public String buildSearchUrl(String searchContent, int page) {
String key = ConfigManager.getStringConfigByKey(ConfigName.ShodanAPIKey);
if (key.equals("")) {
if (StringUtils.isEmpty(key)) {
stderr.println("shodan key not configurated!");
return null;
}
Expand Down
5 changes: 3 additions & 2 deletions src/InternetSearch/Client/ZoomEyeClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.util.List;

import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;

Expand Down Expand Up @@ -82,7 +83,7 @@ public boolean hasNextPage(String respbody,int currentPage) {
@Override
public String buildSearchUrl(String searchContent, int page) {
String key = ConfigManager.getStringConfigByKey(ConfigName.ZoomEyeAPIKey);
if (key.equals("")) {
if (StringUtils.isEmpty(key)) {
stderr.println("zoomeye key not configurated!");
return null;
}
Expand All @@ -109,7 +110,7 @@ public byte[] buildRawData(String searchContent, int page) {

searchContent = URLEncoder.encode(searchContent);
String key = ConfigManager.getStringConfigByKey(ConfigName.ZoomEyeAPIKey);
if (key.equals("")) {
if (StringUtils.isEmpty(key)) {
stderr.println("zoomeye key not configurated!");
return null;
}
Expand Down
18 changes: 12 additions & 6 deletions src/InternetSearch/HttpClientOfBurp.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

import java.net.URL;

import org.apache.commons.io.FileUtils;

import burp.BurpExtender;
import burp.HelperPlus;
import burp.IBurpExtenderCallbacks;
import burp.IExtensionHelpers;
import burp.IHttpRequestResponse;
import burp.IHttpService;
import title.LineEntry;


public class HttpClientOfBurp {
private static Logger logger = new Logger("HttpClientOfBurp_log.txt", 10 * 1024 * 1024);//10M


public static IHttpService getHttpService(URL url) {
IBurpExtenderCallbacks callbacks = BurpExtender.getCallbacks();
IExtensionHelpers helpers = callbacks.getHelpers();
Expand Down Expand Up @@ -50,12 +50,18 @@ public static String doRequest(URL url,byte[] byteRequest) {

IHttpService service =getHttpService(url);
IHttpRequestResponse message = callbacks.makeHttpRequest(service, byteRequest);

HelperPlus getter = new HelperPlus(helpers);
int code = getter.getStatusCode(message);
if (code != 200) {
logger.log(new String(message.getRequest()));
logger.log(new String(message.getResponse()));
BurpExtender.getStderr().print("see log file for more info: "+logger.getLogFile());
try {
//将debug请求存储到title中
LineEntry entry = new LineEntry(message);
entry.addComment("API Search Debug Info");
BurpExtender.getGui().getTitlePanel().getTitleTable().getLineTableModel().addNewLineEntry(entry);
} catch (Exception e) {
e.printStackTrace();
}
return "";
}
byte[] byteBody = getter.getBody(false, message);
Expand Down
6 changes: 0 additions & 6 deletions src/InternetSearch/Logger.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,15 @@ public Logger(String filePath, long maxFileSize) {
this.logFile = new File(filePath);
this.maxFileSize = maxFileSize;
}



public File getLogFile() {
return logFile;
}



public void setLogFile(File logFile) {
this.logFile = logFile;
}



public void log(String message) {
// 检查文件大小是否超过限制
if (logFile.length() >= maxFileSize) {
Expand Down
12 changes: 6 additions & 6 deletions src/InternetSearch/SearchResultEntry.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package InternetSearch;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

import burp.BurpExtender;
import burp.IPAddressUtils;
import domain.DomainManager;
import domain.target.TargetEntry;
import org.apache.commons.lang3.StringUtils;
import utils.DomainNameUtils;
import utils.URLUtils;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

public class SearchResultEntry {
private int port = -1;
private String host = "";
Expand Down Expand Up @@ -197,7 +197,7 @@ public void AddToTarget() {
}
}

if (this.rootDomain != null && !this.rootDomain.equals("")) {
if (StringUtils.isEmpty(this.rootDomain)) {
domainResult.addToTargetAndSubDomain(this.rootDomain,true);
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/Tools/SuperJTextArea.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.apache.commons.io.FileUtils;

import burp.BurpExtender;
import org.apache.commons.lang3.StringUtils;
import title.search.History;

public class SuperJTextArea extends JTextArea {
Expand Down Expand Up @@ -193,7 +194,7 @@ public void paste() {
@Override
public void setText(String Text) {
try {
if (!history.contains(Text) && !Text.equals("")){
if (!history.contains(Text) && StringUtils.isNotEmpty(Text)){
history.addRecord(Text);
}

Expand Down
9 changes: 5 additions & 4 deletions src/Tools/ToolPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import javax.swing.event.DocumentListener;

import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.text.StringEscapeUtils;

import GUI.GUIMain;
Expand Down Expand Up @@ -365,7 +366,7 @@ protected void action() {
@Override
protected void action() {
String content = inputTextArea.getText();
if (null != content && !content.equals("")) {
if (StringUtils.isNotEmpty(content)) {

List<String> lines = Commons.textToLines(content);
HashMap<String, Set<String>> ipAndPorts = new HashMap<String,Set<String>>();
Expand Down Expand Up @@ -402,7 +403,7 @@ protected void action() {
@Override
protected void action() {
String content = inputTextArea.getText();
if (null != content && !content.equals("")) {
if (StringUtils.isNotEmpty(content)) {

List<String> lines = Commons.textToLines(content);
List<String> result = new ArrayList<String>();
Expand Down Expand Up @@ -430,7 +431,7 @@ protected void action() {
@Override
protected void action() {
String content = inputTextArea.getText();
if (null != content && !content.equals("")) {
if (StringUtils.isNotEmpty(content)) {
List<String> result = new ArrayList<String>();

List<String> iplist = GrepUtils.grepIP(content);
Expand Down Expand Up @@ -465,7 +466,7 @@ protected void action() {
@Override
protected void action() {
String content = inputTextArea.getText();
if (null != content && !content.equals("")) {
if (StringUtils.isNotEmpty(content)) {

List<String> result = new ArrayList<String>();

Expand Down
7 changes: 4 additions & 3 deletions src/base/Commons.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import javax.swing.JTextArea;

import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.net.util.SubnetUtils;

import com.ibm.icu.text.CharsetDetector;
Expand Down Expand Up @@ -122,7 +123,7 @@ public static void browserOpen(Object url,String browser) throws Exception{


public static byte[] buildCookieRequest(IExtensionHelpers helpers,String cookie, byte[] request) {
if (cookie != null && !cookie.equals("")){
if (StringUtils.isNotEmpty(cookie)){
if (!cookie.startsWith("Cookie: ")){
cookie = "Cookie: "+cookie;
}
Expand Down Expand Up @@ -222,7 +223,7 @@ public static String detectCharset(byte[] requestOrResponse){
public static List<Integer> Port_prompt(Component prompt, String str){
String defaultPorts = "8080,8000,8443";
String user_input = JOptionPane.showInputDialog(prompt, str,defaultPorts);
if (null == user_input || user_input.trim().equals("")) return null;
if (StringUtils.isEmpty(user_input)) return null;
List<Integer> portList = new ArrayList<Integer>();
for (String port: user_input.trim().split(",")) {
int portint = Integer.parseInt(port);
Expand Down Expand Up @@ -313,7 +314,7 @@ public static String formateURLString(String urlString) {
urlString = urlString.replace(host, newHost);
}

if (path.equals("")) {
if (StringUtils.isEmpty(path)) {
urlString = urlString+"/";
}
} catch (MalformedURLException e) {
Expand Down
3 changes: 2 additions & 1 deletion src/base/DictFileReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

Expand Down Expand Up @@ -70,7 +71,7 @@ private List<String> readLinebyNumber(int beginIndex,int NumberToRead,String suf
continue;
}else if (currentIndex >= beginIndex && currentIndex <= endIndex) {
lineStr = lineStr.trim();
if (!lineStr.equals("")) {
if (StringUtils.isNotEmpty(lineStr)) {
dicts.add(lineStr+suffix);
//dicts.addAll(AltDomainGenerator.genKeywordDomain(Config.specialKeywords, lineStr, suffix));
}
Expand Down
Loading

0 comments on commit 600dab6

Please sign in to comment.