Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
S
StreamMon
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
SexHackMe
StreamMon
Commits
846476b2
Commit
846476b2
authored
Nov 19, 2024
by
nextime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update for websockets
parent
5779325d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
6 deletions
+26
-6
streammon.py
streammon.py
+26
-6
No files found.
streammon.py
View file @
846476b2
import
platform
import
asyncio
from
playwright.async_api
import
async_playwright
import
argparse
import
os
from
datetime
import
datetime
from
pathlib
import
Path
async
def
monitor_stream
ate
(
log_path
):
async
def
monitor_stream
(
log_path
,
domain
):
async
with
async_playwright
()
as
p
:
browser
=
await
p
.
chromium
.
connect_over_cdp
(
"http://localhost:9222"
)
while
True
:
contexts
=
browser
.
contexts
for
context
in
contexts
:
for
page
in
context
.
pages
:
if
"performerclient.streamatemodels.com"
in
page
.
url
:
if
domain
in
page
.
url
:
print
(
f
"Found Streamate tab"
)
await
monitor_requests
(
page
,
log_path
)
...
...
@@ -39,20 +39,40 @@ async def monitor_requests(page, log_path):
f
.
write
(
str
(
log_body
))
f
.
write
(
"
\n\n
"
)
async
def
log_websocket
(
ws
):
def
writelog
(
payload
,
origin
,
url
):
print
(
origin
+
": "
+
str
(
payload
)
+
"
\n
"
)
log_entry
=
f
"[{datetime.now()}] WS: {origin} {url} -> Message: "
with
open
(
log_path
,
'a'
)
as
f
:
f
.
write
(
log_entry
)
f
.
write
(
origin
+
": "
)
f
.
write
(
str
(
payload
)
+
"
\n\n
"
)
print
(
f
"WebSocket opened: {ws.url}"
)
ws
.
on
(
"framesent"
,
lambda
payload
:
writelog
(
payload
,
'framesent'
,
ws
.
url
))
ws
.
on
(
"framereceived"
,
lambda
payload
:
writelog
(
payload
,
'framereceived'
,
ws
.
url
))
ws
.
on
(
"close"
,
lambda
payload
:
print
(
"WebSocket closed"
))
page
.
on
(
"request"
,
log_request
)
page
.
on
(
"response"
,
log_response
)
page
.
on
(
"websocket"
,
log_websocket
)
while
True
:
await
asyncio
.
sleep
(
1
)
if
__name__
==
"__main__"
:
lpath
=
str
(
Path
(
Path
.
home
(),
Path
(
'streamon.log'
)))
parser
=
argparse
.
ArgumentParser
(
description
=
"Monitor Streamate requests"
)
parser
.
add_argument
(
"--log_path"
,
type
=
str
,
default
=
"streamate_requests.log"
,
parser
.
add_argument
(
"--log_path"
,
type
=
str
,
default
=
lpath
,
help
=
"Path to the log file"
)
parser
.
add_argument
(
"--domain"
,
type
=
str
,
default
=
"performerclient.streamatemodels.com"
,
help
=
"URL to monitor"
)
args
=
parser
.
parse_args
()
log_dir
=
os
.
path
.
dirname
(
args
.
log_path
)
if
log_dir
and
not
os
.
path
.
exists
(
log_dir
):
os
.
makedirs
(
log_dir
)
asyncio
.
run
(
monitor_stream
ate
(
args
.
log_path
))
asyncio
.
run
(
monitor_stream
(
args
.
log_path
,
args
.
domain
))
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment