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
e2c392f9
Commit
e2c392f9
authored
Jun 17, 2017
by
Honfika
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Format code
parent
711fc5e5
Show whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
263 additions
and
257 deletions
+263
-257
SessionEventArgs.cs
Titanium.Web.Proxy/EventArguments/SessionEventArgs.cs
+2
-3
CustomBufferedStream.cs
Titanium.Web.Proxy/Helpers/CustomBufferedStream.cs
+1
-2
HttpHelper.cs
Titanium.Web.Proxy/Helpers/HttpHelper.cs
+0
-1
ProxyInfo.cs
Titanium.Web.Proxy/Helpers/ProxyInfo.cs
+1
-1
RunTime.cs
Titanium.Web.Proxy/Helpers/RunTime.cs
+2
-2
WinHttpHandle.cs
Titanium.Web.Proxy/Helpers/WinHttp/WinHttpHandle.cs
+1
-1
WinHttpWebProxyFinder.cs
Titanium.Web.Proxy/Helpers/WinHttp/WinHttpWebProxyFinder.cs
+3
-3
HttpWebClient.cs
Titanium.Web.Proxy/Http/HttpWebClient.cs
+2
-2
Request.cs
Titanium.Web.Proxy/Http/Request.cs
+1
-4
Response.cs
Titanium.Web.Proxy/Http/Response.cs
+3
-4
EndPoint.cs
Titanium.Web.Proxy/Models/EndPoint.cs
+0
-1
CertificateManager.cs
Titanium.Web.Proxy/Network/CertificateManager.cs
+1
-1
TcpConnectionFactory.cs
Titanium.Web.Proxy/Network/Tcp/TcpConnectionFactory.cs
+4
-4
Common.cs
Titanium.Web.Proxy/Network/WinAuth/Security/Common.cs
+18
-1
LittleEndian.cs
Titanium.Web.Proxy/Network/WinAuth/Security/LittleEndian.cs
+178
-169
Message.cs
Titanium.Web.Proxy/Network/WinAuth/Security/Message.cs
+31
-40
WinAuthEndPoint.cs
...ium.Web.Proxy/Network/WinAuth/Security/WinAuthEndPoint.cs
+0
-1
WinAuthHandler.cs
Titanium.Web.Proxy/Network/WinAuth/WinAuthHandler.cs
+4
-5
ProxyServer.cs
Titanium.Web.Proxy/ProxyServer.cs
+5
-3
RequestHandler.cs
Titanium.Web.Proxy/RequestHandler.cs
+2
-2
ResponseHandler.cs
Titanium.Web.Proxy/ResponseHandler.cs
+3
-3
WinAuthHandler.cs
Titanium.Web.Proxy/WinAuthHandler.cs
+1
-4
No files found.
Titanium.Web.Proxy/EventArguments/SessionEventArgs.cs
View file @
e2c392f9
...
@@ -48,7 +48,6 @@ namespace Titanium.Web.Proxy.EventArguments
...
@@ -48,7 +48,6 @@ namespace Titanium.Web.Proxy.EventArguments
/// </summary>
/// </summary>
public
Guid
Id
=>
WebSession
.
RequestId
;
public
Guid
Id
=>
WebSession
.
RequestId
;
/// <summary>
/// <summary>
/// Should we send the request again
/// Should we send the request again
/// </summary>
/// </summary>
...
...
Titanium.Web.Proxy/Helpers/CustomBufferedStream.cs
View file @
e2c392f9
...
@@ -359,7 +359,7 @@ namespace Titanium.Web.Proxy.Helpers
...
@@ -359,7 +359,7 @@ namespace Titanium.Web.Proxy.Helpers
/// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources.</param>
/// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources.</param>
protected
override
void
Dispose
(
bool
disposing
)
protected
override
void
Dispose
(
bool
disposing
)
{
{
if
(!
disposed
)
if
(!
disposed
)
{
{
disposed
=
true
;
disposed
=
true
;
baseStream
.
Dispose
();
baseStream
.
Dispose
();
...
@@ -367,7 +367,6 @@ namespace Titanium.Web.Proxy.Helpers
...
@@ -367,7 +367,6 @@ namespace Titanium.Web.Proxy.Helpers
streamBuffer
=
null
;
streamBuffer
=
null
;
readCallback
=
null
;
readCallback
=
null
;
}
}
}
}
/// <summary>
/// <summary>
...
...
Titanium.Web.Proxy/Helpers/HttpHelper.cs
View file @
e2c392f9
...
@@ -68,7 +68,6 @@ namespace Titanium.Web.Proxy.Helpers
...
@@ -68,7 +68,6 @@ namespace Titanium.Web.Proxy.Helpers
int
idx
=
hostname
.
IndexOf
(
ProxyConstants
.
DotSplit
);
int
idx
=
hostname
.
IndexOf
(
ProxyConstants
.
DotSplit
);
var
rootDomain
=
hostname
.
Substring
(
idx
+
1
);
var
rootDomain
=
hostname
.
Substring
(
idx
+
1
);
return
"*."
+
rootDomain
;
return
"*."
+
rootDomain
;
}
}
//return as it is
//return as it is
...
...
Titanium.Web.Proxy/Helpers/ProxyInfo.cs
View file @
e2c392f9
...
@@ -36,7 +36,7 @@ namespace Titanium.Web.Proxy.Helpers
...
@@ -36,7 +36,7 @@ namespace Titanium.Web.Proxy.Helpers
if
(
proxyServer
!=
null
)
if
(
proxyServer
!=
null
)
{
{
Proxies
=
GetSystemProxyValues
(
proxyServer
).
ToDictionary
(
x
=>
x
.
ProtocolType
);
Proxies
=
GetSystemProxyValues
(
proxyServer
).
ToDictionary
(
x
=>
x
.
ProtocolType
);
}
}
if
(
proxyOverride
!=
null
)
if
(
proxyOverride
!=
null
)
...
...
Titanium.Web.Proxy/Helpers/RunTime.cs
View file @
e2c392f9
...
@@ -12,7 +12,7 @@ namespace Titanium.Web.Proxy.Helpers
...
@@ -12,7 +12,7 @@ namespace Titanium.Web.Proxy.Helpers
/// </summary>
/// </summary>
/// <returns></returns>
/// <returns></returns>
private
static
readonly
Lazy
<
bool
>
isRunningOnMono
private
static
readonly
Lazy
<
bool
>
isRunningOnMono
=
new
Lazy
<
bool
>(()=>
Type
.
GetType
(
"Mono.Runtime"
)
!=
null
);
=
new
Lazy
<
bool
>(()
=>
Type
.
GetType
(
"Mono.Runtime"
)
!=
null
);
/// <summary>
/// <summary>
/// Is running on Mono?
/// Is running on Mono?
...
...
Titanium.Web.Proxy/Helpers/WinHttp/WinHttpHandle.cs
View file @
e2c392f9
Titanium.Web.Proxy/Helpers/WinHttp/WinHttpWebProxyFinder.cs
View file @
e2c392f9
Titanium.Web.Proxy/Http/HttpWebClient.cs
View file @
e2c392f9
Titanium.Web.Proxy/Http/Request.cs
View file @
e2c392f9
...
@@ -431,7 +431,6 @@ namespace Titanium.Web.Proxy.Http
...
@@ -431,7 +431,6 @@ namespace Titanium.Web.Proxy.Http
RequestHeaders
.
Remove
(
header
.
Name
);
RequestHeaders
.
Remove
(
header
.
Name
);
return
true
;
return
true
;
}
}
}
}
else
if
(
NonUniqueRequestHeaders
.
ContainsKey
(
header
.
Name
))
else
if
(
NonUniqueRequestHeaders
.
ContainsKey
(
header
.
Name
))
{
{
...
@@ -460,7 +459,5 @@ namespace Titanium.Web.Proxy.Http
...
@@ -460,7 +459,5 @@ namespace Titanium.Web.Proxy.Http
RequestBody
=
null
;
RequestBody
=
null
;
RequestBody
=
null
;
RequestBody
=
null
;
}
}
}
}
}
}
Titanium.Web.Proxy/Http/Response.cs
View file @
e2c392f9
...
@@ -249,7 +249,7 @@ namespace Titanium.Web.Proxy.Http
...
@@ -249,7 +249,7 @@ namespace Titanium.Web.Proxy.Http
/// <returns></returns>
/// <returns></returns>
public
bool
HeaderExists
(
string
name
)
public
bool
HeaderExists
(
string
name
)
{
{
if
(
ResponseHeaders
.
ContainsKey
(
name
)
if
(
ResponseHeaders
.
ContainsKey
(
name
)
||
NonUniqueResponseHeaders
.
ContainsKey
(
name
))
||
NonUniqueResponseHeaders
.
ContainsKey
(
name
))
{
{
return
true
;
return
true
;
...
@@ -336,7 +336,7 @@ namespace Titanium.Web.Proxy.Http
...
@@ -336,7 +336,7 @@ namespace Titanium.Web.Proxy.Http
/// False if no header exists with given name</returns>
/// False if no header exists with given name</returns>
public
bool
RemoveHeader
(
string
headerName
)
public
bool
RemoveHeader
(
string
headerName
)
{
{
if
(
ResponseHeaders
.
ContainsKey
(
headerName
))
if
(
ResponseHeaders
.
ContainsKey
(
headerName
))
{
{
ResponseHeaders
.
Remove
(
headerName
);
ResponseHeaders
.
Remove
(
headerName
);
return
true
;
return
true
;
...
@@ -363,7 +363,6 @@ namespace Titanium.Web.Proxy.Http
...
@@ -363,7 +363,6 @@ namespace Titanium.Web.Proxy.Http
ResponseHeaders
.
Remove
(
header
.
Name
);
ResponseHeaders
.
Remove
(
header
.
Name
);
return
true
;
return
true
;
}
}
}
}
else
if
(
NonUniqueResponseHeaders
.
ContainsKey
(
header
.
Name
))
else
if
(
NonUniqueResponseHeaders
.
ContainsKey
(
header
.
Name
))
{
{
...
...
Titanium.Web.Proxy/Models/EndPoint.cs
View file @
e2c392f9
...
@@ -53,7 +53,6 @@ namespace Titanium.Web.Proxy.Models
...
@@ -53,7 +53,6 @@ namespace Titanium.Web.Proxy.Models
public
bool
IpV6Enabled
=>
Equals
(
IpAddress
,
IPAddress
.
IPv6Any
)
public
bool
IpV6Enabled
=>
Equals
(
IpAddress
,
IPAddress
.
IPv6Any
)
||
Equals
(
IpAddress
,
IPAddress
.
IPv6Loopback
)
||
Equals
(
IpAddress
,
IPAddress
.
IPv6Loopback
)
||
Equals
(
IpAddress
,
IPAddress
.
IPv6None
);
||
Equals
(
IpAddress
,
IPAddress
.
IPv6None
);
}
}
/// <summary>
/// <summary>
...
...
Titanium.Web.Proxy/Network/CertificateManager.cs
View file @
e2c392f9
Titanium.Web.Proxy/Network/Tcp/TcpConnectionFactory.cs
View file @
e2c392f9
Titanium.Web.Proxy/Network/WinAuth/Security/Common.cs
View file @
e2c392f9
...
@@ -6,25 +6,30 @@
...
@@ -6,25 +6,30 @@
internal
class
Common
internal
class
Common
{
{
#
region
Private
constants
#
region
Private
constants
private
const
int
ISC_REQ_REPLAY_DETECT
=
0x00000004
;
private
const
int
ISC_REQ_REPLAY_DETECT
=
0x00000004
;
private
const
int
ISC_REQ_SEQUENCE_DETECT
=
0x00000008
;
private
const
int
ISC_REQ_SEQUENCE_DETECT
=
0x00000008
;
private
const
int
ISC_REQ_CONFIDENTIALITY
=
0x00000010
;
private
const
int
ISC_REQ_CONFIDENTIALITY
=
0x00000010
;
private
const
int
ISC_REQ_CONNECTION
=
0x00000800
;
private
const
int
ISC_REQ_CONNECTION
=
0x00000800
;
#
endregion
#
endregion
internal
static
uint
NewContextAttributes
=
0
;
internal
static
uint
NewContextAttributes
=
0
;
internal
static
SecurityInteger
NewLifeTime
=
new
SecurityInteger
(
0
);
internal
static
SecurityInteger
NewLifeTime
=
new
SecurityInteger
(
0
);
#
region
internal
constants
#
region
internal
constants
internal
const
int
StandardContextAttributes
=
ISC_REQ_CONFIDENTIALITY
|
ISC_REQ_REPLAY_DETECT
|
ISC_REQ_SEQUENCE_DETECT
|
ISC_REQ_CONNECTION
;
internal
const
int
StandardContextAttributes
=
ISC_REQ_CONFIDENTIALITY
|
ISC_REQ_REPLAY_DETECT
|
ISC_REQ_SEQUENCE_DETECT
|
ISC_REQ_CONNECTION
;
internal
const
int
SecurityNativeDataRepresentation
=
0x10
;
internal
const
int
SecurityNativeDataRepresentation
=
0x10
;
internal
const
int
MaximumTokenSize
=
12288
;
internal
const
int
MaximumTokenSize
=
12288
;
internal
const
int
SecurityCredentialsOutbound
=
2
;
internal
const
int
SecurityCredentialsOutbound
=
2
;
internal
const
int
SuccessfulResult
=
0
;
internal
const
int
SuccessfulResult
=
0
;
internal
const
int
IntermediateResult
=
0x90312
;
internal
const
int
IntermediateResult
=
0x90312
;
#
endregion
#
endregion
#
region
internal
enumerations
#
region
internal
enumerations
internal
enum
SecurityBufferType
internal
enum
SecurityBufferType
{
{
SECBUFFER_VERSION
=
0
,
SECBUFFER_VERSION
=
0
,
...
@@ -38,22 +43,31 @@
...
@@ -38,22 +43,31 @@
{
{
// The client sets this flag to indicate that it supports Unicode strings.
// The client sets this flag to indicate that it supports Unicode strings.
NegotiateUnicode
=
0x00000001
,
NegotiateUnicode
=
0x00000001
,
// This is set to indicate that the client supports OEM strings.
// This is set to indicate that the client supports OEM strings.
NegotiateOem
=
0x00000002
,
NegotiateOem
=
0x00000002
,
// This requests that the server send the authentication target with the Type 2 reply.
// This requests that the server send the authentication target with the Type 2 reply.
RequestTarget
=
0x00000004
,
RequestTarget
=
0x00000004
,
// Indicates that NTLM authentication is supported.
// Indicates that NTLM authentication is supported.
NegotiateNtlm
=
0x00000200
,
NegotiateNtlm
=
0x00000200
,
// When set, the client will send with the message the name of the domain in which the workstation has membership.
// When set, the client will send with the message the name of the domain in which the workstation has membership.
NegotiateDomainSupplied
=
0x00001000
,
NegotiateDomainSupplied
=
0x00001000
,
// Indicates that the client is sending its workstation name with the message.
// Indicates that the client is sending its workstation name with the message.
NegotiateWorkstationSupplied
=
0x00002000
,
NegotiateWorkstationSupplied
=
0x00002000
,
// Indicates that communication between the client and server after authentication should carry a "dummy" signature.
// Indicates that communication between the client and server after authentication should carry a "dummy" signature.
NegotiateAlwaysSign
=
0x00008000
,
NegotiateAlwaysSign
=
0x00008000
,
// Indicates that this client supports the NTLM2 signing and sealing scheme; if negotiated, this can also affect the response calculations.
// Indicates that this client supports the NTLM2 signing and sealing scheme; if negotiated, this can also affect the response calculations.
NegotiateNtlm2Key
=
0x00080000
,
NegotiateNtlm2Key
=
0x00080000
,
// Indicates that this client supports strong (128-bit) encryption.
// Indicates that this client supports strong (128-bit) encryption.
Negotiate128
=
0x20000000
,
Negotiate128
=
0x20000000
,
// Indicates that this client supports medium (56-bit) encryption.
// Indicates that this client supports medium (56-bit) encryption.
Negotiate56
=
(
unchecked
((
int
)
0x80000000
))
Negotiate56
=
(
unchecked
((
int
)
0x80000000
))
}
}
...
@@ -74,9 +88,11 @@
...
@@ -74,9 +88,11 @@
/* Use NTLMv2 only. */
/* Use NTLMv2 only. */
NTLMv2_only
,
NTLMv2_only
,
}
}
#
endregion
#
endregion
#
region
internal
structures
#
region
internal
structures
[
StructLayout
(
LayoutKind
.
Sequential
)]
[
StructLayout
(
LayoutKind
.
Sequential
)]
internal
struct
SecurityHandle
internal
struct
SecurityHandle
{
{
...
@@ -102,6 +118,7 @@
...
@@ -102,6 +118,7 @@
{
{
internal
uint
LowPart
;
internal
uint
LowPart
;
internal
int
HighPart
;
internal
int
HighPart
;
internal
SecurityInteger
(
int
dummy
)
internal
SecurityInteger
(
int
dummy
)
{
{
LowPart
=
0
;
LowPart
=
0
;
...
@@ -152,7 +169,6 @@
...
@@ -152,7 +169,6 @@
[
StructLayout
(
LayoutKind
.
Sequential
)]
[
StructLayout
(
LayoutKind
.
Sequential
)]
internal
struct
SecurityBufferDesciption
:
IDisposable
internal
struct
SecurityBufferDesciption
:
IDisposable
{
{
internal
int
ulVersion
;
internal
int
ulVersion
;
internal
int
cBuffers
;
internal
int
cBuffers
;
internal
IntPtr
pBuffers
;
//Point to SecBuffer
internal
IntPtr
pBuffers
;
//Point to SecBuffer
...
@@ -260,6 +276,7 @@
...
@@ -260,6 +276,7 @@
return
(
buffer
);
return
(
buffer
);
}
}
}
}
#
endregion
#
endregion
}
}
}
}
Titanium.Web.Proxy/Network/WinAuth/Security/LittleEndian.cs
View file @
e2c392f9
...
@@ -33,11 +33,11 @@ namespace Titanium.Web.Proxy.Network.WinAuth.Security
...
@@ -33,11 +33,11 @@ namespace Titanium.Web.Proxy.Network.WinAuth.Security
internal
sealed
class
LittleEndian
internal
sealed
class
LittleEndian
{
{
private
LittleEndian
()
private
LittleEndian
()
{
{
}
}
unsafe
private
static
byte
[]
GetUShortBytes
(
byte
*
bytes
)
unsafe
private
static
byte
[]
GetUShortBytes
(
byte
*
bytes
)
{
{
if
(
BitConverter
.
IsLittleEndian
)
if
(
BitConverter
.
IsLittleEndian
)
{
{
...
@@ -47,7 +47,7 @@ namespace Titanium.Web.Proxy.Network.WinAuth.Security
...
@@ -47,7 +47,7 @@ namespace Titanium.Web.Proxy.Network.WinAuth.Security
return
new
[]
{
bytes
[
1
],
bytes
[
0
]
};
return
new
[]
{
bytes
[
1
],
bytes
[
0
]
};
}
}
unsafe
private
static
byte
[]
GetUIntBytes
(
byte
*
bytes
)
unsafe
private
static
byte
[]
GetUIntBytes
(
byte
*
bytes
)
{
{
if
(
BitConverter
.
IsLittleEndian
)
if
(
BitConverter
.
IsLittleEndian
)
{
{
...
@@ -57,193 +57,202 @@ namespace Titanium.Web.Proxy.Network.WinAuth.Security
...
@@ -57,193 +57,202 @@ namespace Titanium.Web.Proxy.Network.WinAuth.Security
return
new
[]
{
bytes
[
3
],
bytes
[
2
],
bytes
[
1
],
bytes
[
0
]
};
return
new
[]
{
bytes
[
3
],
bytes
[
2
],
bytes
[
1
],
bytes
[
0
]
};
}
}
unsafe
private
static
byte
[]
GetULongBytes
(
byte
*
bytes
)
unsafe
private
static
byte
[]
GetULongBytes
(
byte
*
bytes
)
{
{
if
(
BitConverter
.
IsLittleEndian
)
if
(
BitConverter
.
IsLittleEndian
)
{
{
return
new
[]
{
bytes
[
0
],
bytes
[
1
],
bytes
[
2
],
bytes
[
3
],
return
new
[]
bytes
[
4
],
bytes
[
5
],
bytes
[
6
],
bytes
[
7
]
};
{
bytes
[
0
],
bytes
[
1
],
bytes
[
2
],
bytes
[
3
],
bytes
[
4
],
bytes
[
5
],
bytes
[
6
],
bytes
[
7
]
};
}
}
return
new
[]
{
bytes
[
7
],
bytes
[
6
],
bytes
[
5
],
bytes
[
4
],
return
new
[]
bytes
[
3
],
bytes
[
2
],
bytes
[
1
],
bytes
[
0
]
};
{
bytes
[
7
],
bytes
[
6
],
bytes
[
5
],
bytes
[
4
],
bytes
[
3
],
bytes
[
2
],
bytes
[
1
],
bytes
[
0
]
};
}
}
internal
static
byte
[]
GetBytes
(
bool
value
)
internal
static
byte
[]
GetBytes
(
bool
value
)
{
{
return
new
[]
{
value
?
(
byte
)
1
:
(
byte
)
0
};
return
new
[]
{
value
?
(
byte
)
1
:
(
byte
)
0
};
}
}
unsafe
internal
static
byte
[]
GetBytes
(
char
value
)
unsafe
internal
static
byte
[]
GetBytes
(
char
value
)
{
{
return
GetUShortBytes
((
byte
*)
&
value
);
return
GetUShortBytes
((
byte
*)
&
value
);
}
}
unsafe
internal
static
byte
[]
GetBytes
(
short
value
)
unsafe
internal
static
byte
[]
GetBytes
(
short
value
)
{
{
return
GetUShortBytes
((
byte
*)
&
value
);
return
GetUShortBytes
((
byte
*)
&
value
);
}
}
unsafe
internal
static
byte
[]
GetBytes
(
int
value
)
unsafe
internal
static
byte
[]
GetBytes
(
int
value
)
{
{
return
GetUIntBytes
((
byte
*)
&
value
);
return
GetUIntBytes
((
byte
*)
&
value
);
}
}
unsafe
internal
static
byte
[]
GetBytes
(
long
value
)
unsafe
internal
static
byte
[]
GetBytes
(
long
value
)
{
{
return
GetULongBytes
((
byte
*)
&
value
);
return
GetULongBytes
((
byte
*)
&
value
);
}
}
unsafe
internal
static
byte
[]
GetBytes
(
ushort
value
)
unsafe
internal
static
byte
[]
GetBytes
(
ushort
value
)
{
{
return
GetUShortBytes
((
byte
*)
&
value
);
return
GetUShortBytes
((
byte
*)
&
value
);
}
}
unsafe
internal
static
byte
[]
GetBytes
(
uint
value
)
unsafe
internal
static
byte
[]
GetBytes
(
uint
value
)
{
{
return
GetUIntBytes
((
byte
*)
&
value
);
return
GetUIntBytes
((
byte
*)
&
value
);
}
}
unsafe
internal
static
byte
[]
GetBytes
(
ulong
value
)
unsafe
internal
static
byte
[]
GetBytes
(
ulong
value
)
{
{
return
GetULongBytes
((
byte
*)
&
value
);
return
GetULongBytes
((
byte
*)
&
value
);
}
}
unsafe
internal
static
byte
[]
GetBytes
(
float
value
)
unsafe
internal
static
byte
[]
GetBytes
(
float
value
)
{
{
return
GetUIntBytes
((
byte
*)
&
value
);
return
GetUIntBytes
((
byte
*)
&
value
);
}
}
unsafe
internal
static
byte
[]
GetBytes
(
double
value
)
unsafe
internal
static
byte
[]
GetBytes
(
double
value
)
{
{
return
GetULongBytes
((
byte
*)
&
value
);
return
GetULongBytes
((
byte
*)
&
value
);
}
}
unsafe
private
static
void
UShortFromBytes
(
byte
*
dst
,
byte
[]
src
,
int
startIndex
)
unsafe
private
static
void
UShortFromBytes
(
byte
*
dst
,
byte
[]
src
,
int
startIndex
)
{
{
if
(
BitConverter
.
IsLittleEndian
)
if
(
BitConverter
.
IsLittleEndian
)
{
{
dst
[
0
]
=
src
[
startIndex
];
dst
[
0
]
=
src
[
startIndex
];
dst
[
1
]
=
src
[
startIndex
+
1
];
dst
[
1
]
=
src
[
startIndex
+
1
];
}
}
else
else
{
{
dst
[
0
]
=
src
[
startIndex
+
1
];
dst
[
0
]
=
src
[
startIndex
+
1
];
dst
[
1
]
=
src
[
startIndex
];
dst
[
1
]
=
src
[
startIndex
];
}
}
}
}
unsafe
private
static
void
UIntFromBytes
(
byte
*
dst
,
byte
[]
src
,
int
startIndex
)
unsafe
private
static
void
UIntFromBytes
(
byte
*
dst
,
byte
[]
src
,
int
startIndex
)
{
{
if
(
BitConverter
.
IsLittleEndian
)
if
(
BitConverter
.
IsLittleEndian
)
{
{
dst
[
0
]
=
src
[
startIndex
];
dst
[
0
]
=
src
[
startIndex
];
dst
[
1
]
=
src
[
startIndex
+
1
];
dst
[
1
]
=
src
[
startIndex
+
1
];
dst
[
2
]
=
src
[
startIndex
+
2
];
dst
[
2
]
=
src
[
startIndex
+
2
];
dst
[
3
]
=
src
[
startIndex
+
3
];
dst
[
3
]
=
src
[
startIndex
+
3
];
}
}
else
else
{
{
dst
[
0
]
=
src
[
startIndex
+
3
];
dst
[
0
]
=
src
[
startIndex
+
3
];
dst
[
1
]
=
src
[
startIndex
+
2
];
dst
[
1
]
=
src
[
startIndex
+
2
];
dst
[
2
]
=
src
[
startIndex
+
1
];
dst
[
2
]
=
src
[
startIndex
+
1
];
dst
[
3
]
=
src
[
startIndex
];
dst
[
3
]
=
src
[
startIndex
];
}
}
}
}
unsafe
private
static
void
ULongFromBytes
(
byte
*
dst
,
byte
[]
src
,
int
startIndex
)
unsafe
private
static
void
ULongFromBytes
(
byte
*
dst
,
byte
[]
src
,
int
startIndex
)
{
if
(
BitConverter
.
IsLittleEndian
)
{
{
if
(
BitConverter
.
IsLittleEndian
)
{
for
(
int
i
=
0
;
i
<
8
;
++
i
)
for
(
int
i
=
0
;
i
<
8
;
++
i
)
dst
[
i
]
=
src
[
startIndex
+
i
];
dst
[
i
]
=
src
[
startIndex
+
i
];
}
else
{
}
else
{
for
(
int
i
=
0
;
i
<
8
;
++
i
)
for
(
int
i
=
0
;
i
<
8
;
++
i
)
dst
[
i
]
=
src
[
startIndex
+
(
7
-
i
)];
dst
[
i
]
=
src
[
startIndex
+
(
7
-
i
)];
}
}
}
}
internal
static
bool
ToBoolean
(
byte
[]
value
,
int
startIndex
)
internal
static
bool
ToBoolean
(
byte
[]
value
,
int
startIndex
)
{
{
return
value
[
startIndex
]
!=
0
;
return
value
[
startIndex
]
!=
0
;
}
}
unsafe
internal
static
char
ToChar
(
byte
[]
value
,
int
startIndex
)
unsafe
internal
static
char
ToChar
(
byte
[]
value
,
int
startIndex
)
{
{
char
ret
;
char
ret
;
UShortFromBytes
((
byte
*)
&
ret
,
value
,
startIndex
);
UShortFromBytes
((
byte
*)
&
ret
,
value
,
startIndex
);
return
ret
;
return
ret
;
}
}
unsafe
internal
static
short
ToInt16
(
byte
[]
value
,
int
startIndex
)
unsafe
internal
static
short
ToInt16
(
byte
[]
value
,
int
startIndex
)
{
{
short
ret
;
short
ret
;
UShortFromBytes
((
byte
*)
&
ret
,
value
,
startIndex
);
UShortFromBytes
((
byte
*)
&
ret
,
value
,
startIndex
);
return
ret
;
return
ret
;
}
}
unsafe
internal
static
int
ToInt32
(
byte
[]
value
,
int
startIndex
)
unsafe
internal
static
int
ToInt32
(
byte
[]
value
,
int
startIndex
)
{
{
int
ret
;
int
ret
;
UIntFromBytes
((
byte
*)
&
ret
,
value
,
startIndex
);
UIntFromBytes
((
byte
*)
&
ret
,
value
,
startIndex
);
return
ret
;
return
ret
;
}
}
unsafe
internal
static
long
ToInt64
(
byte
[]
value
,
int
startIndex
)
unsafe
internal
static
long
ToInt64
(
byte
[]
value
,
int
startIndex
)
{
{
long
ret
;
long
ret
;
ULongFromBytes
((
byte
*)
&
ret
,
value
,
startIndex
);
ULongFromBytes
((
byte
*)
&
ret
,
value
,
startIndex
);
return
ret
;
return
ret
;
}
}
unsafe
internal
static
ushort
ToUInt16
(
byte
[]
value
,
int
startIndex
)
unsafe
internal
static
ushort
ToUInt16
(
byte
[]
value
,
int
startIndex
)
{
{
ushort
ret
;
ushort
ret
;
UShortFromBytes
((
byte
*)
&
ret
,
value
,
startIndex
);
UShortFromBytes
((
byte
*)
&
ret
,
value
,
startIndex
);
return
ret
;
return
ret
;
}
}
unsafe
internal
static
uint
ToUInt32
(
byte
[]
value
,
int
startIndex
)
unsafe
internal
static
uint
ToUInt32
(
byte
[]
value
,
int
startIndex
)
{
{
uint
ret
;
uint
ret
;
UIntFromBytes
((
byte
*)
&
ret
,
value
,
startIndex
);
UIntFromBytes
((
byte
*)
&
ret
,
value
,
startIndex
);
return
ret
;
return
ret
;
}
}
unsafe
internal
static
ulong
ToUInt64
(
byte
[]
value
,
int
startIndex
)
unsafe
internal
static
ulong
ToUInt64
(
byte
[]
value
,
int
startIndex
)
{
{
ulong
ret
;
ulong
ret
;
ULongFromBytes
((
byte
*)
&
ret
,
value
,
startIndex
);
ULongFromBytes
((
byte
*)
&
ret
,
value
,
startIndex
);
return
ret
;
return
ret
;
}
}
unsafe
internal
static
float
ToSingle
(
byte
[]
value
,
int
startIndex
)
unsafe
internal
static
float
ToSingle
(
byte
[]
value
,
int
startIndex
)
{
{
float
ret
;
float
ret
;
UIntFromBytes
((
byte
*)
&
ret
,
value
,
startIndex
);
UIntFromBytes
((
byte
*)
&
ret
,
value
,
startIndex
);
return
ret
;
return
ret
;
}
}
unsafe
internal
static
double
ToDouble
(
byte
[]
value
,
int
startIndex
)
unsafe
internal
static
double
ToDouble
(
byte
[]
value
,
int
startIndex
)
{
{
double
ret
;
double
ret
;
ULongFromBytes
((
byte
*)
&
ret
,
value
,
startIndex
);
ULongFromBytes
((
byte
*)
&
ret
,
value
,
startIndex
);
return
ret
;
return
ret
;
}
}
...
...
Titanium.Web.Proxy/Network/WinAuth/Security/Message.cs
View file @
e2c392f9
...
@@ -42,36 +42,28 @@ namespace Titanium.Web.Proxy.Network.WinAuth.Security
...
@@ -42,36 +42,28 @@ namespace Titanium.Web.Proxy.Network.WinAuth.Security
{
{
static
private
readonly
byte
[]
header
=
{
0x4e
,
0x54
,
0x4c
,
0x4d
,
0x53
,
0x53
,
0x50
,
0x00
};
static
private
readonly
byte
[]
header
=
{
0x4e
,
0x54
,
0x4c
,
0x4d
,
0x53
,
0x53
,
0x50
,
0x00
};
internal
Message
(
byte
[]
message
)
internal
Message
(
byte
[]
message
)
{
{
type
=
3
;
type
=
3
;
Decode
(
message
);
Decode
(
message
);
}
}
/// <summary>
/// <summary>
/// Domain name
/// Domain name
/// </summary>
/// </summary>
internal
string
Domain
internal
string
Domain
{
get
;
private
set
;
}
{
get
;
private
set
;
}
/// <summary>
/// <summary>
/// Username
/// Username
/// </summary>
/// </summary>
internal
string
Username
internal
string
Username
{
get
;
private
set
;
}
{
get
;
private
set
;
}
private
readonly
int
type
;
private
readonly
int
type
;
internal
Common
.
NtlmFlags
Flags
{
get
;
set
;
}
internal
Common
.
NtlmFlags
Flags
{
get
;
set
;
}
// methods
// methods
private
void
Decode
(
byte
[]
message
)
private
void
Decode
(
byte
[]
message
)
{
{
//base.Decode (message);
//base.Decode (message);
...
@@ -90,10 +82,10 @@ namespace Titanium.Web.Proxy.Network.WinAuth.Security
...
@@ -90,10 +82,10 @@ namespace Titanium.Web.Proxy.Network.WinAuth.Security
throw
new
ArgumentException
(
msg
,
"message"
);
throw
new
ArgumentException
(
msg
,
"message"
);
}
}
if
(
LittleEndian
.
ToUInt16
(
message
,
56
)
!=
message
.
Length
)
if
(
LittleEndian
.
ToUInt16
(
message
,
56
)
!=
message
.
Length
)
{
{
string
msg
=
"Invalid Type3 message length."
;
string
msg
=
"Invalid Type3 message length."
;
throw
new
ArgumentException
(
msg
,
"message"
);
throw
new
ArgumentException
(
msg
,
"message"
);
}
}
if
(
message
.
Length
>=
64
)
if
(
message
.
Length
>=
64
)
...
@@ -105,18 +97,18 @@ namespace Titanium.Web.Proxy.Network.WinAuth.Security
...
@@ -105,18 +97,18 @@ namespace Titanium.Web.Proxy.Network.WinAuth.Security
Flags
=
(
Common
.
NtlmFlags
)
0x8201
;
Flags
=
(
Common
.
NtlmFlags
)
0x8201
;
}
}
int
domLen
=
LittleEndian
.
ToUInt16
(
message
,
28
);
int
domLen
=
LittleEndian
.
ToUInt16
(
message
,
28
);
int
domOff
=
LittleEndian
.
ToUInt16
(
message
,
32
);
int
domOff
=
LittleEndian
.
ToUInt16
(
message
,
32
);
Domain
=
DecodeString
(
message
,
domOff
,
domLen
);
Domain
=
DecodeString
(
message
,
domOff
,
domLen
);
int
userLen
=
LittleEndian
.
ToUInt16
(
message
,
36
);
int
userLen
=
LittleEndian
.
ToUInt16
(
message
,
36
);
int
userOff
=
LittleEndian
.
ToUInt16
(
message
,
40
);
int
userOff
=
LittleEndian
.
ToUInt16
(
message
,
40
);
Username
=
DecodeString
(
message
,
userOff
,
userLen
);
Username
=
DecodeString
(
message
,
userOff
,
userLen
);
}
}
string
DecodeString
(
byte
[]
buffer
,
int
offset
,
int
len
)
string
DecodeString
(
byte
[]
buffer
,
int
offset
,
int
len
)
{
{
if
((
Flags
&
Common
.
NtlmFlags
.
NegotiateUnicode
)
!=
0
)
if
((
Flags
&
Common
.
NtlmFlags
.
NegotiateUnicode
)
!=
0
)
{
{
...
@@ -134,6 +126,5 @@ namespace Titanium.Web.Proxy.Network.WinAuth.Security
...
@@ -134,6 +126,5 @@ namespace Titanium.Web.Proxy.Network.WinAuth.Security
}
}
return
(
LittleEndian
.
ToUInt32
(
message
,
8
)
==
type
);
return
(
LittleEndian
.
ToUInt32
(
message
,
8
)
==
type
);
}
}
}
}
}
}
Titanium.Web.Proxy/Network/WinAuth/Security/WinAuthEndPoint.cs
View file @
e2c392f9
...
@@ -216,7 +216,6 @@ namespace Titanium.Web.Proxy.Network.WinAuth.Security
...
@@ -216,7 +216,6 @@ namespace Titanium.Web.Proxy.Network.WinAuth.Security
ref
SecurityHandle
phCredential
,
//SecHandle //PCtxtHandle ref
ref
SecurityHandle
phCredential
,
//SecHandle //PCtxtHandle ref
ref
SecurityInteger
ptsExpiry
);
//PTimeStamp //TimeStamp ref
ref
SecurityInteger
ptsExpiry
);
//PTimeStamp //TimeStamp ref
#
endregion
#
endregion
}
}
}
}
Titanium.Web.Proxy/Network/WinAuth/WinAuthHandler.cs
View file @
e2c392f9
...
@@ -41,6 +41,5 @@ namespace Titanium.Web.Proxy.Network.WinAuth
...
@@ -41,6 +41,5 @@ namespace Titanium.Web.Proxy.Network.WinAuth
return
string
.
Concat
(
" "
,
Convert
.
ToBase64String
(
tokenBytes
));
return
string
.
Concat
(
" "
,
Convert
.
ToBase64String
(
tokenBytes
));
}
}
}
}
}
}
Titanium.Web.Proxy/ProxyServer.cs
View file @
e2c392f9
...
@@ -409,7 +409,9 @@ namespace Titanium.Web.Proxy
...
@@ -409,7 +409,9 @@ namespace Titanium.Web.Proxy
systemProxySettingsManager
.
SetProxy
(
systemProxySettingsManager
.
SetProxy
(
Equals
(
endPoint
.
IpAddress
,
IPAddress
.
Any
)
|
Equals
(
endPoint
.
IpAddress
,
IPAddress
.
Any
)
|
Equals
(
endPoint
.
IpAddress
,
IPAddress
.
Loopback
)
?
"127.0.0.1"
:
endPoint
.
IpAddress
.
ToString
(),
Equals
(
endPoint
.
IpAddress
,
IPAddress
.
Loopback
)
?
"127.0.0.1"
:
endPoint
.
IpAddress
.
ToString
(),
endPoint
.
Port
,
endPoint
.
Port
,
protocolType
);
protocolType
);
...
...
Titanium.Web.Proxy/RequestHandler.cs
View file @
e2c392f9
Titanium.Web.Proxy/ResponseHandler.cs
View file @
e2c392f9
...
@@ -32,13 +32,13 @@ namespace Titanium.Web.Proxy
...
@@ -32,13 +32,13 @@ namespace Titanium.Web.Proxy
await
args
.
WebSession
.
ReceiveResponse
();
await
args
.
WebSession
.
ReceiveResponse
();
//check for windows authentication
//check for windows authentication
if
(
EnableWinAuth
if
(
EnableWinAuth
&&
!
RunTime
.
IsRunningOnMono
&&
!
RunTime
.
IsRunningOnMono
&&
args
.
WebSession
.
Response
.
ResponseStatusCode
==
"401"
)
&&
args
.
WebSession
.
Response
.
ResponseStatusCode
==
"401"
)
{
{
var
disposed
=
await
Handle401UnAuthorized
(
args
);
var
disposed
=
await
Handle401UnAuthorized
(
args
);
if
(
disposed
)
if
(
disposed
)
{
{
return
true
;
return
true
;
}
}
...
...
Titanium.Web.Proxy/WinAuthHandler.cs
View file @
e2c392f9
...
@@ -115,7 +115,6 @@ namespace Titanium.Web.Proxy
...
@@ -115,7 +115,6 @@ namespace Titanium.Web.Proxy
{
{
args
.
WebSession
.
Request
.
ContentLength
=
0
;
args
.
WebSession
.
Request
.
ContentLength
=
0
;
}
}
}
}
//challenge value will start with any of the scheme selected
//challenge value will start with any of the scheme selected
else
else
...
@@ -136,7 +135,6 @@ namespace Titanium.Web.Proxy
...
@@ -136,7 +135,6 @@ namespace Titanium.Web.Proxy
args
.
WebSession
.
Request
.
ContentLength
args
.
WebSession
.
Request
.
ContentLength
=
args
.
WebSession
.
Request
.
RequestBody
.
Length
;
=
args
.
WebSession
.
Request
.
RequestBody
.
Length
;
}
}
}
}
//Need to revisit this.
//Need to revisit this.
...
@@ -154,6 +152,5 @@ namespace Titanium.Web.Proxy
...
@@ -154,6 +152,5 @@ namespace Titanium.Web.Proxy
return
false
;
return
false
;
}
}
}
}
}
}
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