Skip to content
Sign up
Sign in
This repository
Explore
Features
Enterprise
Blog
Star
3
Fork
0
frida
/
geoshark
Code
Issues
Pull Requests
Pulse
Graphs
HTTPS
clone URL
Subversion
checkout URL
You can clone with
HTTPS
or
Subversion
.
Download ZIP
Permalink
Browse code
Hook socket APIs
Loading branch information
...
commit
e051573795bbcbc59ec9bd2861ac7128d927a637
1 parent
065cbc5
oleavr
authored
Jun 22, 2014
Unified
Split
Showing
1 changed file
with
48 additions
and
0 deletions
.
+
48
−
0
agent.js
48
agent.js
Show notes
View
@@ -25,3 +25,51 @@ send({
threadId: Process.getCurrentThreadId()
}
});
+
+var socketModule = {
+ "windows": "ws2_32.dll",
+ "darwin": "libSystem.B.dylib",
+ "linux": "libc-2.19.so"
+};
+var socketFunctionPrefixes = [
+ "connect",
+ "recv",
+ "send",
+ "read",
+ "write"
+];
+function isSocketFunction(name) {
+ return socketFunctionPrefixes.some(function (prefix) {
+ return name.indexOf(prefix) === 0;
+ });
+}
+Module.enumerateExports(socketModule[Process.platform], {
+ onMatch: function (exp) {
+ if (exp.type === "function"
+ && isSocketFunction(exp.name)) {
+ Interceptor.attach(exp.address, {
+ onEnter: function (args) {
+ this.fd = args[0].toInt32();
+ },
+ onLeave: function (retval) {
+ var fd = this.fd;
+ if (Socket.type(fd) !== "tcp")
+ return;
+ var address = Socket.peerAddress(fd);
+ if (address === null)
+ return;
+ send({
+ name: "socket-activity",
+ payload: {
+ fd: fd,
+ func: exp.name,
+ address: address
+ }
+ });
+ }
+ });
+ }
+ },
+ onComplete: function () {
+ }
+});
Toggle all file notes
Please
sign in
to comment.
Something went wrong with that request. Please try again.