Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TLMSP curl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CYBER - Cyber Security
TS 103 523 MSP
TLMSP
TLMSP curl
Commits
fdd91b22
Commit
fdd91b22
authored
24 years ago
by
Daniel Stenberg
Browse files
Options
Downloads
Patches
Plain Diff
moved out the FTP part
parent
7ea4551b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/httpserver.pl
+12
-135
12 additions, 135 deletions
tests/httpserver.pl
with
12 additions
and
135 deletions
tests/httpserver.pl
+
12
−
135
View file @
fdd91b22
...
...
@@ -9,19 +9,19 @@ sub spawn; # forward declaration
sub
logmsg
{
#print "$0 $$: @_ at ", scalar localtime, "\n"
}
my
$port
=
$ARGV
[
0
];
my
$proto
=
getprotobyname
('
tcp
')
||
6
;
$port
=
$
1
if
$port
=~
/(\d+)/
;
# untaint port number
my
$verbose
=
0
;
# set to 1 for debugging
my
$protocol
;
if
(
$ARGV
[
1
]
=~
/^ftp$/i
)
{
$protocol
=
"
FTP
";
}
else
{
$protocol
=
"
HTTP
";
}
my
$port
=
8999
;
# just a default
do
{
if
(
$ARGV
[
0
]
eq
"
-v
")
{
$verbose
=
1
;
}
elsif
(
$ARGV
[
0
]
=~
/^(\d+)$/
)
{
$port
=
$
1
;
}
}
while
(
shift
@ARGV
);
my
$
verbose
=
0
;
# set to 1 for debugging
my
$
proto
=
getprotobyname
('
tcp
')
||
6
;
socket
(
Server
,
PF_INET
,
SOCK_STREAM
,
$proto
)
||
die
"
socket: $!
";
setsockopt
(
Server
,
SOL_SOCKET
,
SO_REUSEADDR
,
...
...
@@ -29,7 +29,7 @@ setsockopt(Server, SOL_SOCKET, SO_REUSEADDR,
bind
(
Server
,
sockaddr_in
(
$port
,
INADDR_ANY
))
||
die
"
bind: $!
";
listen
(
Server
,
SOMAXCONN
)
||
die
"
listen: $!
";
print
"
$protocol
server started on port
$port
\n
";
print
"
HTTP
server started on port
$port
\n
";
open
(
PID
,
"
>.server.pid
");
print
PID
$$
;
...
...
@@ -44,55 +44,6 @@ sub REAPER {
logmsg
"
reaped
$waitedpid
"
.
(
$?
?
"
with exit $?
"
:
'');
}
# USER is ok in fresh state
my
%commandok
=
(
"
USER
"
=>
"
fresh
",
"
PASS
"
=>
"
passwd
",
# "PASV" => "loggedin", we can't handle PASV yet
"
PORT
"
=>
"
loggedin
",
);
my
%statechange
=
(
'
USER
'
=>
'
passwd
',
# USER goes to passwd state
'
PASS
'
=>
'
loggedin
',
# PASS goes to loggedin state
'
PORT
'
=>
'
ported
',
# PORT goes to ported
);
my
%displaytext
=
('
USER
'
=>
'
331 We are happy you popped in!
',
# output FTP line
'
PASS
'
=>
'
230 Welcome you silly person
',
);
my
%commandfunc
=
(
'
PORT
',
\
&PORT_command
);
sub
PORT_command
{
my
$arg
=
$_
[
0
];
print
STDERR
"
fooo:
$arg
\n
";
# "193,15,23,1,172,201"
if
(
$arg
!~
/(\d+),(\d+),(\d+),(\d+),(\d+),(\d+)/
)
{
print
STDERR
"
bad PORT-line:
$arg
\n
";
print
"
314 silly you, go away
\r\n
";
return
1
;
}
my
$iaddr
=
inet_aton
("
$1.$2.$3.$4
");
my
$paddr
=
sockaddr_in
((
$
5
<<
8
)
+
$
6
,
$iaddr
);
my
$proto
=
getprotobyname
('
tcp
')
||
6
;
socket
(
SOCK
,
PF_INET
,
SOCK_STREAM
,
$proto
)
||
die
"
major failure
";
print
STDERR
"
socket()
\n
";
connect
(
SOCK
,
$paddr
)
||
return
1
;
print
STDERR
"
connect()
\n
";
my
$line
;
while
(
defined
(
$line
=
<
SOCK
>
))
{
print
STDERR
$line
;
}
close
(
SOCK
);
print
STDERR
"
close()
\n
";
}
$SIG
{
CHLD
}
=
\
&REAPER
;
for
(
$waitedpid
=
0
;
...
...
@@ -109,80 +60,6 @@ for ( $waitedpid = 0;
spawn
sub
{
my
(
$request
,
$path
,
$ver
,
$left
,
$cl
);
if
(
$protocol
eq
"
FTP
")
{
# < 220 pm1 FTP server (SunOS 5.7) ready.
# > USER anonymous
# < 331 Guest login ok, send ident as password.
# > PASS curl_by_daniel@haxx.se
# < 230 Guest login ok, access restrictions apply.
# * We have successfully logged in
# * Connected to pm1 (193.15.23.1)
# > PASV
# < 227 Entering Passive Mode (193,15,23,1,231,59)
# * Connecting to pm1 (193.15.23.1) port 59195
# > TYPE A
# < 200 Type set to A.
# > LIST
# < 150 ASCII data connection for /bin/ls (193.15.23.1,59196) (0 bytes).
# * Getting file with size: -1
# flush data:
$|
=
1
;
print
"
220-running the curl suite test server
\r\n
",
"
220-running the curl suite test server
\r\n
",
"
220 running the curl suite test server
\r\n
";
my
$state
=
"
fresh
";
while
(
1
)
{
last
unless
defined
(
$_
=
<
STDIN
>
);
# Remove trailing CRLF.
s/[\n\r]+$//
;
unless
(
m/^([A-Z]{3,4})\s?(.*)/i
)
{
print
STDERR
"
badly formed command received:
"
.
$_
;
exit
0
;
}
my
$FTPCMD
=
$
1
;
my
$FTPARG
=
$
2
;
my
$full
=
$_
;
print
STDERR
"
GOT: ($1)
$_
\n
";
my
$ok
=
$commandok
{
$FTPCMD
};
if
(
$ok
!~
/$state/
)
{
print
"
314
$FTPCMD
not OK (
$ok
) in state:
$state
!
\r\n
";
exit
;
}
$state
=
$statechange
{
$FTPCMD
};
if
(
$state
eq
"")
{
print
"
314 Wwwwweeeeird internal error state:
$state
\r\n
";
exit
;
}
# see if the new state is a function caller.
my
$func
=
$commandfunc
{
$FTPCMD
};
if
(
$func
)
{
# it is!
spawn
\
&$func
(
$FTPARG
);
}
print
STDERR
"
gone to state
$state
\n
";
my
$text
=
$displaytext
{
$FTPCMD
};
print
"
$text
\r\n
";
}
exit
;
}
# otherwise, we're doing HTTP
my
@headers
;
while
(
<
STDIN
>
)
{
if
(
$_
=~
/([A-Z]*) (.*) HTTP\/1.(\d)/
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment