Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
T
Titanium-Web-Proxy
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
Administrator
Titanium-Web-Proxy
Commits
42e35359
Commit
42e35359
authored
Aug 31, 2019
by
Honfika
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow to gt the dectypted data from a tunnel
parent
65357243
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
90 additions
and
23 deletions
+90
-23
MainWindow.xaml.cs
examples/Titanium.Web.Proxy.Examples.Wpf/MainWindow.xaml.cs
+49
-20
TunnelConnectEventArgs.cs
...tanium.Web.Proxy/EventArguments/TunnelConnectEventArgs.cs
+35
-0
ExplicitClientHandler.cs
src/Titanium.Web.Proxy/ExplicitClientHandler.cs
+6
-3
No files found.
examples/Titanium.Web.Proxy.Examples.Wpf/MainWindow.xaml.cs
View file @
42e35359
...
...
@@ -231,7 +231,6 @@ namespace Titanium.Web.Proxy.Examples.Wpf
};
//if (isTunnelConnect || e.HttpClient.Request.UpgradeToWebSocket)
{
e
.
DataReceived
+=
(
sender
,
args
)
=>
{
var
session
=
(
SessionEventArgsBase
)
sender
;
...
...
@@ -244,6 +243,9 @@ namespace Titanium.Web.Proxy.Examples.Wpf
}
li
.
ReceivedDataCount
+=
args
.
Count
;
AppendTransferLog
(
session
.
GetHashCode
()
+
(
isTunnelConnect
?
"_tunnel"
:
""
)
+
"_received"
,
args
.
Buffer
,
args
.
Offset
,
args
.
Count
);
}
};
...
...
@@ -259,14 +261,41 @@ namespace Titanium.Web.Proxy.Examples.Wpf
}
li
.
SentDataCount
+=
args
.
Count
;
AppendTransferLog
(
session
.
GetHashCode
()
+
(
isTunnelConnect
?
"_tunnel"
:
""
)
+
"_sent"
,
args
.
Buffer
,
args
.
Offset
,
args
.
Count
);
}
};
if
(
e
is
TunnelConnectSessionEventArgs
te
)
{
te
.
DecryptedDataReceived
+=
(
sender
,
args
)
=>
{
var
session
=
(
SessionEventArgsBase
)
sender
;
AppendTransferLog
(
session
.
GetHashCode
()
+
"_decrypted_received"
,
args
.
Buffer
,
args
.
Offset
,
args
.
Count
);
};
te
.
DecryptedDataSent
+=
(
sender
,
args
)
=>
{
var
session
=
(
SessionEventArgsBase
)
sender
;
AppendTransferLog
(
session
.
GetHashCode
()
+
"_decrypted_sent"
,
args
.
Buffer
,
args
.
Offset
,
args
.
Count
);
};
}
item
.
Update
();
return
item
;
}
private
void
AppendTransferLog
(
string
fileName
,
byte
[]
buffer
,
int
offset
,
int
count
)
{
//string basePath = @"c:\!titanium\";
//using (var fs = new FileStream(basePath + fileName, FileMode.Append, FileAccess.Write, FileShare.Read))
//{
// fs.Write(buffer, offset, count);
//}
}
private
string
TunnelTypeToString
(
TunnelType
tunnelType
)
{
switch
(
tunnelType
)
...
...
src/Titanium.Web.Proxy/EventArguments/TunnelConnectEventArgs.cs
View file @
42e35359
...
...
@@ -2,6 +2,7 @@
using
System.Threading
;
using
Titanium.Web.Proxy.Http
;
using
Titanium.Web.Proxy.Models
;
using
Titanium.Web.Proxy.StreamExtended.Network
;
namespace
Titanium.Web.Proxy.EventArguments
{
...
...
@@ -40,5 +41,39 @@ namespace Titanium.Web.Proxy.EventArguments
internal
set
=>
isHttpsConnect
=
value
;
}
/// <summary>
/// Fired when decrypted data is sent within this session to server/client.
/// </summary>
public
event
EventHandler
<
DataEventArgs
>
DecryptedDataSent
;
/// <summary>
/// Fired when decrypted data is received within this session from client/server.
/// </summary>
public
event
EventHandler
<
DataEventArgs
>
DecryptedDataReceived
;
internal
void
OnDecryptedDataSent
(
byte
[]
buffer
,
int
offset
,
int
count
)
{
try
{
DecryptedDataSent
?.
Invoke
(
this
,
new
DataEventArgs
(
buffer
,
offset
,
count
));
}
catch
(
Exception
ex
)
{
ExceptionFunc
(
new
Exception
(
"Exception thrown in user event"
,
ex
));
}
}
internal
void
OnDecryptedDataReceived
(
byte
[]
buffer
,
int
offset
,
int
count
)
{
try
{
DecryptedDataReceived
?.
Invoke
(
this
,
new
DataEventArgs
(
buffer
,
offset
,
count
));
}
catch
(
Exception
ex
)
{
ExceptionFunc
(
new
Exception
(
"Exception thrown in user event"
,
ex
));
}
}
}
}
src/Titanium.Web.Proxy/ExplicitClientHandler.cs
View file @
42e35359
...
...
@@ -216,6 +216,8 @@ namespace Titanium.Web.Proxy
// HTTPS server created - we can now decrypt the client's traffic
clientStream
=
new
CustomBufferedStream
(
sslStream
,
BufferPool
);
clientStream
.
DataRead
+=
(
o
,
args
)
=>
connectArgs
.
OnDecryptedDataSent
(
args
.
Buffer
,
args
.
Offset
,
args
.
Count
);
clientStream
.
DataWrite
+=
(
o
,
args
)
=>
connectArgs
.
OnDecryptedDataReceived
(
args
.
Buffer
,
args
.
Offset
,
args
.
Count
);
clientStreamWriter
=
new
HttpResponseWriter
(
clientStream
,
BufferPool
);
}
catch
(
Exception
e
)
...
...
@@ -286,7 +288,8 @@ namespace Titanium.Web.Proxy
if
(!
clientStream
.
IsClosed
&&
!
connection
.
Stream
.
IsClosed
)
{
await
TcpHelper
.
SendRaw
(
clientStream
,
connection
.
Stream
,
BufferPool
,
null
,
null
,
connectArgs
.
CancellationTokenSource
,
ExceptionFunc
);
null
,
null
,
connectArgs
.
CancellationTokenSource
,
ExceptionFunc
);
}
}
finally
...
...
@@ -336,8 +339,8 @@ namespace Titanium.Web.Proxy
await
connection
.
StreamWriter
.
WriteLineAsync
(
cancellationToken
);
#if NETCOREAPP2_1
await
Http2Helper
.
SendHttp2
(
clientStream
,
connection
.
Stream
,
BufferPool
.
BufferSize
,
(
buffer
,
offset
,
count
)
=>
{
connectArgs
.
OnDataSent
(
buffer
,
offset
,
count
);
},
(
buffer
,
offset
,
count
)
=>
{
connectArgs
.
OnDataReceived
(
buffer
,
offset
,
count
);
},
(
buffer
,
offset
,
count
)
=>
{
connectArgs
.
OnD
ecryptedD
ataSent
(
buffer
,
offset
,
count
);
},
(
buffer
,
offset
,
count
)
=>
{
connectArgs
.
OnD
ecryptedD
ataReceived
(
buffer
,
offset
,
count
);
},
()
=>
new
SessionEventArgs
(
this
,
endPoint
,
cancellationTokenSource
)
{
ProxyClient
=
{
Connection
=
clientConnection
},
...
...
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