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
987dafc9
Commit
987dafc9
authored
Dec 26, 2019
by
Honfika
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
socks 5 username/password authentication
parent
0614f4f9
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
73 additions
and
4 deletions
+73
-4
SessionEventArgsBase.cs
...Titanium.Web.Proxy/EventArguments/SessionEventArgsBase.cs
+5
-0
RequestHandler.cs
src/Titanium.Web.Proxy/RequestHandler.cs
+1
-1
ResponseHandler.cs
src/Titanium.Web.Proxy/ResponseHandler.cs
+1
-1
SocksClientHandler.cs
src/Titanium.Web.Proxy/SocksClientHandler.cs
+66
-2
No files found.
src/Titanium.Web.Proxy/EventArguments/SessionEventArgsBase.cs
View file @
987dafc9
...
...
@@ -140,6 +140,11 @@ namespace Titanium.Web.Proxy.EventArguments
/// </summary>
public
bool
IsTransparent
=>
ProxyEndPoint
is
TransparentProxyEndPoint
;
/// <summary>
/// Is this a SOCKS endpoint?
/// </summary>
public
bool
IsSocks
=>
ProxyEndPoint
is
SocksProxyEndPoint
;
/// <summary>
/// The last exception that happened.
/// </summary>
...
...
src/Titanium.Web.Proxy/RequestHandler.cs
View file @
987dafc9
...
...
@@ -90,7 +90,7 @@ namespace Titanium.Web.Proxy
request
.
Method
=
requestLine
.
Method
;
request
.
HttpVersion
=
requestLine
.
Version
;
if
(!
args
.
IsTransparent
)
if
(!
args
.
IsTransparent
&&
!
args
.
IsSocks
)
{
// proxy authorization check
if
(
connectRequest
==
null
&&
await
checkAuthorization
(
args
)
==
false
)
...
...
src/Titanium.Web.Proxy/ResponseHandler.cs
View file @
987dafc9
...
...
@@ -99,7 +99,7 @@ namespace Titanium.Web.Proxy
response
.
Locked
=
true
;
if
(!
args
.
IsTransparent
)
if
(!
args
.
IsTransparent
&&
!
args
.
IsSocks
)
{
response
.
Headers
.
FixProxyHeaders
();
}
...
...
src/Titanium.Web.Proxy/SocksClientHandler.cs
View file @
987dafc9
using
System
;
using
System.Text
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
Titanium.Web.Proxy.Extensions
;
...
...
@@ -48,13 +49,76 @@ namespace Titanium.Web.Proxy
}
else
if
(
buffer
[
0
]
==
5
)
{
if
(
buffer
[
1
]
==
0
||
buffer
[
2
]
!=
0
)
int
authenticationMethodCount
=
buffer
[
1
];
if
(
read
<
authenticationMethodCount
+
2
)
{
return
;
}
buffer
[
1
]
=
0
;
int
acceptedMethod
=
255
;
for
(
int
i
=
0
;
i
<
authenticationMethodCount
;
i
++)
{
int
method
=
buffer
[
i
+
2
];
if
(
method
==
0
&&
ProxyBasicAuthenticateFunc
==
null
)
{
acceptedMethod
=
0
;
break
;
}
if
(
method
==
2
)
{
acceptedMethod
=
2
;
break
;
}
}
buffer
[
1
]
=
(
byte
)
acceptedMethod
;
await
stream
.
WriteAsync
(
buffer
,
0
,
2
,
cancellationToken
);
if
(
acceptedMethod
==
255
)
{
// no acceptable method
return
;
}
if
(
acceptedMethod
==
2
)
{
read
=
await
stream
.
ReadAsync
(
buffer
,
0
,
buffer
.
Length
,
cancellationToken
);
if
(
read
<
3
||
buffer
[
0
]
!=
1
)
{
// authentication version should be 1
return
;
}
int
userNameLength
=
buffer
[
1
];
if
(
read
<
3
+
userNameLength
)
{
return
;
}
string
userName
=
Encoding
.
ASCII
.
GetString
(
buffer
,
2
,
userNameLength
);
int
passwordLength
=
buffer
[
2
+
userNameLength
];
if
(
read
<
3
+
userNameLength
+
passwordLength
)
{
return
;
}
string
password
=
Encoding
.
ASCII
.
GetString
(
buffer
,
3
+
userNameLength
,
passwordLength
);
bool
success
=
true
;
if
(
ProxySchemeAuthenticateFunc
!=
null
)
{
success
=
await
ProxyBasicAuthenticateFunc
.
Invoke
(
null
,
userName
,
password
);
}
buffer
[
1
]
=
success
?
(
byte
)
0
:
(
byte
)
1
;
await
stream
.
WriteAsync
(
buffer
,
0
,
2
,
cancellationToken
);
if
(!
success
)
{
return
;
}
}
read
=
await
stream
.
ReadAsync
(
buffer
,
0
,
buffer
.
Length
,
cancellationToken
);
if
(
read
<
10
||
buffer
[
1
]
!=
1
)
{
...
...
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