Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
T
tun
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Railgun
tun
Commits
f65c6593
Commit
f65c6593
authored
Jul 02, 2022
by
Manni
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
057e78a1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
12 deletions
+10
-12
.gitignore
.gitignore
+2
-1
main.cpp
main.cpp
+8
-11
No files found.
.gitignore
View file @
f65c6593
# Project exclude paths
cmake-build-debug
.idea
\ No newline at end of file
.idea
.DS_Store
main.cpp
View file @
f65c6593
...
...
@@ -11,22 +11,19 @@
#include <arpa/inet.h>
#include <boost/program_options.hpp>
#define decrypt_package encrypt_package
namespace
po
=
boost
::
program_options
;
in_addr_t
remote
;
auto
cipher
=
(
unsigned
char
*
)
"Mathematics is the art of giving the same name to different things"
;
auto
cipher
=
(
unsigned
char
*
)
"Mathematics is the art of giving the same name to different things
.
"
;
void
encrypt
(
unsigned
char
*
buffer
,
size_t
length
)
{
void
encrypt
_package
(
unsigned
char
*
buffer
,
size_t
length
)
{
for
(
auto
i
=
0
;
i
<
length
;
i
++
)
{
buffer
[
i
]
^=
cipher
[
i
];
}
}
void
decrypt
(
unsigned
char
*
buffer
,
size_t
length
)
{
// xor decrypt is same as encrypt
encrypt
(
buffer
,
length
);
}
// internet -> tun
void
inbound
(
int
raw
,
int
tun
)
{
unsigned
char
buffer
[
ETH_DATA_LEN
];
...
...
@@ -39,7 +36,7 @@ void inbound(int raw, int tun) {
auto
overhead
=
packet
->
ihl
*
4
;
auto
payload
=
buffer
+
overhead
;
auto
payload_length
=
packet_length
-
overhead
;
decrypt
(
payload
,
payload_length
);
decrypt
_package
(
payload
,
payload_length
);
if
(
write
(
tun
,
payload
,
payload_length
)
<
0
)
{
perror
(
"inbound write"
);
}
...
...
@@ -54,7 +51,7 @@ void outbound(int raw, int tun) {
address
.
sin_addr
.
s_addr
=
remote
;
size_t
packet_length
;
while
((
packet_length
=
read
(
tun
,
buffer
,
sizeof
(
buffer
)))
>=
0
)
{
encrypt
(
buffer
,
packet_length
);
encrypt
_package
(
buffer
,
packet_length
);
if
(
sendto
(
raw
,
buffer
,
packet_length
,
0
,
(
sockaddr
*
)
&
address
,
sizeof
(
address
))
<
0
)
{
perror
(
"outbound write"
);
}
...
...
@@ -66,9 +63,9 @@ int main(int argc, char *argv[]) {
po
::
options_description
desc
(
"Allowed options"
);
desc
.
add_options
()
(
"help
"
,
"produce help message
"
)
(
"help
,h"
,
"see how to use me elegantly
"
)
(
"IP,i"
,
po
::
value
<
std
::
string
>
(),
"IP to connect"
)
(
"dev,d"
,
po
::
value
<
std
::
string
>
(),
"tun
device
name"
)
(
"dev,d"
,
po
::
value
<
std
::
string
>
(),
"tun
nel device's
name"
)
(
"postup,p"
,
po
::
value
<
std
::
string
>
(),
"post up script"
);
po
::
variables_map
args
;
...
...
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