{"record":{"id":"0e0e67d0ccccc6e2","repo":"shadow1ng/fscan","slug":"failed-to-login-with-anonymous-s","errorCode":null,"errorMessage":"failed to login with anonymous: %s","messagePattern":"failed to login with anonymous: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugins/services/ms17010_exp.go","lineNumber":151,"sourceCode":"\nfunc smb1AnonymousConnectIPC(address string) (*smbHeader, net.Conn, error) {\n\tconn, err := net.DialTimeout(\"tcp\", address, 10*time.Second)\n\tif err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"failed to connect host: %s\", err)\n\t}\n\tvar ok bool\n\tdefer func() {\n\t\tif !ok {\n\t\t\t_ = conn.Close()\n\t\t}\n\t}()\n\terr = smbClientNegotiate(conn)\n\tif err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"failed to negotiate: %s\", err)\n\t}\n\traw, header, err := smb1AnonymousLogin(conn)\n\tif err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"failed to login with anonymous: %s\", err)\n\t}\n\t_, err = getOSName(raw)\n\tif err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"failed to get OS name: %s\", err)\n\t}\n\t//fmt.Println(\"OS:\", osName)\n\theader, err = treeConnectAndX(conn, address, header.UserID)\n\tif err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"failed to tree connect AndX: %s\", err)\n\t}\n\tok = true\n\treturn header, conn, nil\n}\n\nconst smbHeaderSize = 32\n\ntype smbHeader struct {\n\tServerComponent [4]byte","sourceCodeStart":133,"sourceCodeEnd":169,"githubUrl":"https://github.com/shadow1ng/fscan/blob/95cc12e753bf43de7004e5aef42a9ffba3934303/plugins/services/ms17010_exp.go#L133-L169","documentation":"This error wraps a failure of smb1AnonymousLogin (Session Setup AndX with an empty/anonymous credential) inside smb1AnonymousConnectIPC (plugins/services/ms17010_exp.go:151). smb1AnonymousLogin writes a fixed SMB1 session-setup packet and reads the reply through smb1GetResponse, so failures here are transport-level (write error, malformed/absent response), not credential rejections. The library throws it because the anonymous session must be set up before the OS-name read and IPC tree connect.","triggerScenarios":"The conn.Write of the Session Setup AndX packet fails, or smb1GetResponse fails on the reply: NetBIOS header read error/timeout, invalid message type byte, response shorter than 32 bytes, incomplete body, or unparseable SMB header.","commonSituations":"Target aborts the session when it sees the anonymous/NTLM-less login (hardened or SMB2-only servers); a middlebox resets the flow; the server crashed or dropped the socket after negotiate; scanning a non-Windows SMB implementation that rejects the hardcoded packet layout.","solutions":["Read the wrapped smb1GetResponse/write error to determine if the peer reset vs timed out","Verify the target accepts anonymous (null-session) SMB1 logins; modern/patched servers commonly reject them","Ensure SMB1 is enabled on the target — the login packet is SMB1-only","Retry the host; transient connection drops during scans frequently produce this"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// A host that passed negotiate is usually OK; retry transient login drops\nfor i := 0; i < 3; i++ {\n    h, c, err := smb1AnonymousConnectIPC(addr)\n    if err == nil { _ = c.Close(); return true }\n    if !strings.Contains(err.Error(), \"failed to login with anonymous\") { return false }\n    time.Sleep(time.Second)\n}\nreturn false","typeGuard":null,"tryCatchPattern":"if err != nil {\n    if strings.Contains(err.Error(), \"failed to login with anonymous\") &&\n        isNetworkWrapped(err) { // write/read error, not policy rejection\n        retry()\n    } else {\n        markHostUnsupported()\n    }\n}","preventionTips":["Expect null-session rejections on hardened hosts; treat persistent failure as 'anonymous logins disabled'","Ensure SMB1 is enabled — SMB2-only servers break this fixed SMB1 login packet","Retry with a new connection; the old session is dead after any mid-frame failure","Log the inner error to tell resets (retryable) from clean rejections (not retryable)"],"tags":["smb","smb1","authentication","anonymous-login","session-setup"],"backgroundTag":"authentication-required","analyzedSha":"95cc12e753bf43de7004e5aef42a9ffba3934303","analyzedAt":"2026-09-06T17:07:30.094Z","contentChangedAt":"2026-09-06T17:07:30.094Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}