Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/http/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Http 纯sh+;telnet:没有卷曲,没有wget_Http_Post_Sh_Telnet - Fatal编程技术网

Http 纯sh+;telnet:没有卷曲,没有wget

Http 纯sh+;telnet:没有卷曲,没有wget,http,post,sh,telnet,Http,Post,Sh,Telnet,我正在使用一个旧的android设备(wiko rainbow up 4G android 5.1,如果你想知道的话),唯一真正有效的是telnet(busybox的wget只有--post数据(没有--post文件),curl似乎无法安装(我花了几个小时试图安装它)) 我正在尝试通过http POST将screen.png发送到http服务器 我在纯telnet中为小文本或json文件使用了下面的代码(也花了几个小时) 但当我处理更大的文件时,比如png图像或hexdump。这是行不通的 我怀

我正在使用一个旧的android设备(wiko rainbow up 4G android 5.1,如果你想知道的话),唯一真正有效的是telnet(busybox的wget只有--post数据(没有--post文件),curl似乎无法安装(我花了几个小时试图安装它))

我正在尝试通过http POST将screen.png发送到http服务器

我在纯telnet中为小文本或json文件使用了下面的代码(也花了几个小时)

但当我处理更大的文件时,比如png图像或hexdump。这是行不通的

我怀疑这是由于文件中存在特殊字符造成的。我认为这可能会迫使telnet退出

这个问题很棘手,我被卡住了,但我希望你们中的一位会喜欢这个挑战,通过telnet发布png图像

以下是我用于测试的示例服务器端代码:

文件上传到上传=“./FILE.txt”
边界=$((随机%99999))
HOST=“server.com”
POST_PATH=“/upload.php”
FIELD_NAME=“上传的文件”
TLNET_CONTENT=“-------------------------------------$BOUNDARY
内容配置:表单数据;名称=\“$FIELD\u name\”;文件名=\“$(basename$FILE\u TO\u UPLOAD)\”
$(cat$文件到上传)
-----------------------------$BOUNDARY--“
TLNET_HEADERS=“POST$POST_路径HTTP/1.1
主机:$Host
内容类型:多部分/表单数据;边界=------------------------------------$boundary
内容长度:$($(expr Length“$TLNET_Content”)+100))
连接:保持活动”
TELNET_ALL=“$TLNET_头
$TLNET_内容
"

telnet $主机80 http需要请求行、标题行和空白行,将头与正文分开,以CR/LF对结束,不只是行提要。
FILE_TO_UPLOAD="./file.txt"
BOUNDARY=$((  RANDOM % 99999 ))
HOST="server.com"
POST_PATH="/upload.php"
FIELD_NAME="uploaded_file"

CONTENT=$(printf '%s\n' \
    "-----------------------------$BOUNDARY" \
    "Content-Disposition: form-data; name=\"$FIELD_NAME\"; filename=\"$(basename $FILE_TO_UPLOAD)\""

   cat "$FILE_TO_UPLOAD"

   printf '%s\n' "-----------------------------$BOUNDARY--"
)

{
  printf '%s\r\n' \
    "POST $POST_PATH HTTP/1.1" \
    "Host: $HOST" \
    "Content-Type: multipart/form-data; boundary=---------------------------$BOUNDARY" \
    "Content-Length: $(($(expr length "$CONTENT") + 100 ))" \
    "Connection: keep-alive" \
    "";

  printf '%s\n' "$CONTENT"
} | telnet $HOST 80 
谢谢,, 我不得不修改你的建议,让它在安卓设备上运行,但是

FILE_TO_UPLOAD="./screen.png"
BOUNDARY=$((  RANDOM % 99999 ))
HOST="server.com"
POST_PATH="/upload.php"
FIELD_NAME="uploaded_file"

TLNET_CONTENT=$(printf '%s\n' \
    "-----------------------------$BOUNDARY" \
    "Content-Disposition: form-data; name=\"$FIELD_NAME\"; filename=\"$(basename $FILE_TO_UPLOAD)\"" \
    "";
   cat "$FILE_TO_UPLOAD"
   printf '%s\n' "-----------------------------$BOUNDARY--"
)


{
    printf '%s\n' \
    "POST $POST_PATH HTTP/1.1" \
    "Host: $HOST" \
    "Content-Type: multipart/form-data; boundary=---------------------------$BOUNDARY" \
    "Content-Length: $(($(expr length "$CONTENT") + 100 ))" \
    "Connection: keep-alive" \
    "";
    printf '%s\n' "$TLNET_CONTENT"
} | telnet $HOST 80
它仍然适用于file.txt

然而,我仍然有许多来自telnet的消息,因为png文件不起作用

    Console escape. Commands are:

     l      go to line mode
     c      go to character mode
     z      suspend telnet
     e      exit telnet
    continuing...

    Console escape. Commands are:

     l      go to line mode
     c      go to character mode
     z      suspend telnet
     e      exit telnet
    continuing...

    Console escape. Commands are:

     l      go to line mode
     c      go to character mode
     z      suspend telnet
     e      exit telnet

我终于设法转移了文件。我用过netcat。 如果有一天你使用的是一个非常有限的系统,那么很可能你至少有netcat

在接收端,您必须执行
nc-l-p1234>out.file

这将开始侦听端口1234并存储所有in out.file 注意你的防火墙规则

在发送端
nc-w3[hostname/ip]1234是否不需要
$(cat$FILE\u TO\u UPLOAD)
?抱歉,它只是在清除变量的过程中迷失了方向;那也被修复了。
    Console escape. Commands are:

     l      go to line mode
     c      go to character mode
     z      suspend telnet
     e      exit telnet
    continuing...

    Console escape. Commands are:

     l      go to line mode
     c      go to character mode
     z      suspend telnet
     e      exit telnet
    continuing...

    Console escape. Commands are:

     l      go to line mode
     c      go to character mode
     z      suspend telnet
     e      exit telnet