MCPcopy Index your code
hub / github.com/shadow1ng/fscan / runScan

Method runScan

web/api/scan.go:150–246  ·  view source on GitHub ↗

runScan 执行扫描

(req ScanRequest)

Source from the content-addressed store, hash-verified

148
149// runScan 执行扫描
150func (h *ScanHandler) runScan(req ScanRequest) {
151 ctx, cancel := context.WithCancel(context.Background())
152
153 h.mu.Lock()
154 h.cancelFn = cancel
155 h.mu.Unlock()
156
157 defer func() {
158 cancel()
159 h.mu.Lock()
160 h.cancelFn = nil
161 h.mu.Unlock()
162 common.ClearResultCallback()
163 atomic.StoreInt32(&h.state, int32(ScanStateIdle))
164 h.hub.Broadcast(ws.MsgScanCompleted, map[string]interface{}{
165 "duration": time.Since(h.startTime).Seconds(),
166 "stats": h.results.Stats(),
167 })
168 }()
169
170 // 构建HostInfo
171 info := common.HostInfo{
172 Host: req.Host,
173 }
174
175 // 构建FlagVars
176 fv := &common.FlagVars{}
177 fv.Ports = req.Ports
178 if fv.Ports == "" {
179 fv.Ports = "21,22,23,25,80,110,135,139,143,443,445,465,587,993,995,1433,1521,3306,3389,5432,5900,6379,8080,8443,9000,27017"
180 }
181 fv.ExcludeHosts = req.ExcludeHosts
182 fv.ExcludePorts = req.ExcludePorts
183 fv.ScanMode = req.ScanMode
184 if fv.ScanMode == "" {
185 fv.ScanMode = "all"
186 }
187 fv.ThreadNum = req.ThreadNum
188 if fv.ThreadNum <= 0 {
189 fv.ThreadNum = 600
190 }
191 fv.TimeoutSec = int64(req.Timeout)
192 if fv.TimeoutSec == 0 {
193 fv.TimeoutSec = 3
194 }
195 fv.ModuleThreadNum = req.ModuleThreadNum
196 if fv.ModuleThreadNum <= 0 {
197 fv.ModuleThreadNum = 20
198 }
199 fv.DisablePing = req.DisablePing
200 fv.DisableBrute = req.DisableBrute
201 fv.AliveOnly = req.AliveOnly
202 fv.Username = req.Username
203 fv.Password = req.Password
204 fv.Domain = req.Domain
205 fv.PocPath = req.PocPath
206 fv.PocName = req.PocName
207 fv.PocFull = req.PocFull

Callers 1

StartMethod · 0.95

Calls 15

SetHostPortsMethod · 0.95
ClearResultCallbackFunction · 0.92
BuildConfigFromFlagsFunction · 0.92
NewStateFunction · 0.92
NewScanSessionFunction · 0.92
SetGlobalConfigFunction · 0.92
SetGlobalStateFunction · 0.92
SetResultCallbackFunction · 0.92
RunScanFunction · 0.92
BroadcastMethod · 0.80
CachedHostPortsMethod · 0.80
MergeResultsMethod · 0.80

Tested by

no test coverage detected