-
Notifications
You must be signed in to change notification settings - Fork 604
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remote Desktop Protocol #97
base: onionscan-0.2
Are you sure you want to change the base?
Changes from 6 commits
9917e41
583dcea
6da11ba
612fd51
b16cb63
3dd5e89
3e54284
b70d680
dafdc82
1427b02
f95df2a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,4 +31,18 @@ func (hps *HTTPProtocolScanner) ScanProtocol(hiddenService string, osc *config.O | |
wps := new(spider.OnionSpider) | ||
wps.Crawl(report.HiddenService, osc, report) | ||
} | ||
osc.LogInfo(fmt.Sprintf("Checking %s http(8080)\n", hiddenService)) | ||
conn, err := utils.GetNetworkConnection(hiddenService, 8080, osc.TorProxyAddress, osc.Timeout) | ||
if conn != nil { | ||
conn.Close() | ||
} | ||
if err != nil { | ||
osc.LogInfo("Failed to connect to service on port 8080\n") | ||
report.WebDetected = false | ||
} else { | ||
osc.LogInfo("Found potential service on http(8080)\n") | ||
report.WebDetected = true | ||
wps := new(spider.OnionSpider) | ||
wps.Crawl(report.HiddenService, osc, report) | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's not repeat a bunch of code when all that changes is the port - let's make port number a configurable parameter instead There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree. I'm embarrassed that I opted to duplicate the source code rather than just implement it as a parameter instead because it's such a basic skill and agnostic to programming languages! I'll redo it. I guess I perhaps should start to add useful comments in the source code too. |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package protocol | ||
|
||
import ( | ||
"fmt" | ||
"github.com/s-rah/onionscan/config" | ||
"github.com/s-rah/onionscan/report" | ||
"github.com/s-rah/onionscan/utils" | ||
) | ||
|
||
type RDPProtocolScanner struct { | ||
} | ||
|
||
func (rdps *RDPProtocolScanner) ScanProtocol(hiddenService string, osc *config.OnionScanConfig, report *report.OnionScanReport) { | ||
// RDP | ||
osc.LogInfo(fmt.Sprintf("Checking %s RDP(3389)\n", hiddenService)) | ||
conn, err := utils.GetNetworkConnection(hiddenService, 3389, osc.TorProxyAddress, osc.Timeout) | ||
if err != nil { | ||
osc.LogInfo("Failed to connect to service on port 3389\n") | ||
report.RDPDetected = false | ||
} else { | ||
osc.LogInfo("Detected possible RDP instance\n") | ||
// TODO: Actual Analysis | ||
report.RDPDetected = true | ||
} | ||
if conn != nil { | ||
conn.Close() | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,4 +66,53 @@ func (sps *SSHProtocolScanner) ScanProtocol(hiddenService string, osc *config.On | |
conn.Close() | ||
} | ||
} | ||
osc.LogInfo(fmt.Sprintf("Checking %s ssh(2222)\n", hiddenService)) | ||
conn, err := utils.GetNetworkConnection(hiddenService, 2222, osc.TorProxyAddress, osc.Timeout) | ||
if err != nil { | ||
osc.LogInfo("Failed to connect to service on port 2222\n") | ||
report.SSHDetected = false | ||
if conn != nil { | ||
conn.Close() | ||
} | ||
} else { | ||
// TODO SSH Checking | ||
report.SSHDetected = true | ||
|
||
config := &ssh.ClientConfig{ | ||
HostKeyCallback: func(hostname string, addr net.Addr, key ssh.PublicKey) error { | ||
h := md5.New() | ||
h.Write(key.Marshal()) | ||
|
||
fBytes := h.Sum(nil) | ||
fingerprint := string("") | ||
for i := 0; i < len(fBytes); i++ { | ||
if i+1 != len(fBytes) { | ||
fingerprint = fmt.Sprintf("%s%0.2x:", fingerprint, fBytes[i]) | ||
} else { | ||
fingerprint = fmt.Sprintf("%s%0.2x", fingerprint, fBytes[i]) | ||
} | ||
} | ||
report.SSHKey = fingerprint | ||
osc.LogInfo(fmt.Sprintf("Found SSH Key %s\n", fingerprint)) | ||
// We don't want to continue | ||
return errors.New("error") | ||
}, | ||
} | ||
ssh.NewClientConn(conn, hiddenService+":2222", config) | ||
if conn != nil { | ||
conn.Close() | ||
} | ||
conn, err = utils.GetNetworkConnection(hiddenService, 2222, osc.TorProxyAddress, osc.Timeout) | ||
if err == nil { | ||
reader := bufio.NewReader(conn) | ||
banner, err := reader.ReadString('\n') | ||
if err == nil { | ||
report.SSHBanner = banner | ||
osc.LogInfo(fmt.Sprintf("Found SSH Banner: %s", banner)) | ||
} | ||
} | ||
if conn != nil { | ||
conn.Close() | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above, let's not repeat a bunch of code, let's make port number configurable instead. |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,4 +33,21 @@ func (sps *TLSProtocolScanner) ScanProtocol(hiddenService string, osc *config.On | |
if conn != nil { | ||
conn.Close() | ||
} | ||
osc.LogInfo(fmt.Sprintf("Checking %s TLS(8443)\n", hiddenService)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And again. |
||
conn, err := utils.GetNetworkConnection(hiddenService, 8443, osc.TorProxyAddress, osc.Timeout) | ||
if err != nil { | ||
osc.LogInfo("Failed to connect to service on port 8443\n") | ||
report.TLSDetected = false | ||
} else { | ||
osc.LogInfo("Found TLS Endpoint\n") | ||
report.TLSDetected = true | ||
config := &tls.Config{ | ||
InsecureSkipVerify: true, | ||
} | ||
tlsConn := tls.Client(conn, config) | ||
tlsConn.Write([]byte("GET / HTTP/1.1\r\n\r\n")) | ||
for _, certificate := range tlsConn.ConnectionState().PeerCertificates { | ||
report.Certificates = append(report.Certificates, *certificate) | ||
} | ||
tlsConn.Close() | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,7 @@ type OnionScanReport struct { | |
WebDetected bool `json:"webDetected"` | ||
TLSDetected bool `json:"tlsDetected"` | ||
SSHDetected bool `json:"sshDetected"` | ||
RDPDetected bool `json:"rdpDetected"` | ||
RicochetDetected bool `json:"ricochetDetected"` | ||
IRCDetected bool `json:"ircDetected"` | ||
FTPDetected bool `json:"ftpDetected"` | ||
|
@@ -50,7 +51,8 @@ type OnionScanReport struct { | |
Certificates []x509.Certificate `json:"certificates"` | ||
|
||
// Bitcoin | ||
BitcoinServices map[string]*BitcoinService `json:"bitcoinServices"` | ||
BitcoinAddresses []string `json:"bitcoinAddresses"` | ||
BitcoinServices map[string]*BitcoinService `json:"bitcoinServices"` | ||
|
||
// SSH | ||
SSHKey string `json:"sshKey"` | ||
|
@@ -64,8 +66,20 @@ type OnionScanReport struct { | |
SMTPFingerprint string `json:"smtpFingerprint"` | ||
SMTPBanner string `json:"smtpBanner"` | ||
|
||
ProtocolInfoList []ProtocolInfo `json::"protocolInfoList"` | ||
|
||
NextAction string `json:"lastAction"` | ||
TimedOut bool | ||
TimedOut bool `json:"timedOut"` | ||
} | ||
|
||
type ProtocolInfo struct { | ||
Type string `json:"type"` | ||
Port uint `json:"port:` | ||
Info interface{} `json:"info"` | ||
} | ||
|
||
func (osr *OnionScanReport) AddProtocolInfo(protocolType string, protocolPort uint, protocolInfo interface{}) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This hasn't been finalized yet, and commits shouldn't introduce it or rely on it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll delete it. |
||
osr.ProtocolInfoList = append(osr.ProtocolInfoList, ProtocolInfo{protocolType, protocolPort, protocolInfo}) | ||
} | ||
|
||
func LoadReportFromFile(filename string) (OnionScanReport, error) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merge artifact.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your help @s-rah! I didn't understand that prior to deciding to commit it but I understand it's due to a conflict. I'll amend it. I presume this is the problem causing it to fail to build? If it isn't then I'll redo it all again prior to commit it although perhaps I should also set up automated builds to be certain it's successful. I also changed to default branch that I commit source code to so I'm using the preferred branch. I hadn't committed source code to another branch before and I found it quite confusing!