package chaoba;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.ObjectInputStream.GetField;
import java.io.OutputStream;
import java.net.Socket;
import java.net.UnknownHostException; public class ChaobaClient { public static void main(String[] args) throws Exception { Socket s = new Socket("127.0.0.1", 10009); FileInputStream fileName = getFileName(s);
rece(s);
sendFile(s, fileName);
rece(s);
s.close(); } /*
* 获取发送文件名。发送给服务端。。。本地验证,存在安全隐患。可造成任意文件上传
*
*/
public static FileInputStream getFileName(Socket s) {
try {
File file = new File("C:\\pic\\chaoba.txt");
FileInputStream fileIn = new FileInputStream(file);
String name = file.getName();
OutputStream outputStream = s.getOutputStream();
outputStream.write(name.getBytes());
return fileIn; } catch (Exception e) {
// TODO: handle exception
}
return null; } /*
*
* 发送文件方法
*
*
*/
public static void sendFile(Socket s, FileInputStream fileIn) {
try {
byte[] bufFile = new byte[1024];
OutputStream outputStream2 = s.getOutputStream();
int read = 0;
while ((read = fileIn.read(bufFile)) != -1) {
outputStream2.write(bufFile);
outputStream2.flush(); } s.shutdownOutput();
fileIn.close(); } catch (Exception e) {
// TODO: handle exception
}
} /*
* 接收服务端方法
*
*/
public static void rece(Socket s) { try {
BufferedReader bufIn = new BufferedReader(new InputStreamReader(s.getInputStream()));
String readLine = bufIn.readLine();
System.out.println(readLine);
} catch (Exception e) {
// TODO: handle exception
}
} }
package chaoba;

import java.awt.image.ReplicateScaleFilter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket; public class ChaobaServer { public static void main(String[] args) throws Exception { ServerSocket ss = new ServerSocket(10009);
Socket accept = ss.accept();
String receName = receName(accept);
receFile(accept, receName);
sendRece(accept);
accept.close();
ss.close(); }
public static void sendRece(Socket accept) throws IOException {
OutputStream outputStream1 = accept.getOutputStream();
PrintWriter pw1 = new PrintWriter(outputStream1, true);
pw1.println("成功上传");
} /*
* 接收文件名
*
*
*/
public static String receName(Socket accept) { try {
InputStream inputStream = accept.getInputStream();
byte[] buf = new byte[1024]; int read = inputStream.read(buf);
String name = new String(buf, 0, read);
System.out.println(name); OutputStream outputStream = accept.getOutputStream();
PrintWriter pw = new PrintWriter(outputStream, true);
pw.println("成功获取文件名");
return name;
} catch (Exception e) {
// TODO: handle exception
}
return null;
} public static void receFile(Socket accept, String name) { try {
FileOutputStream fileOut = new FileOutputStream(name);
byte[] bufFile = new byte[1024];
InputStream inputStream2 = accept.getInputStream();
int read2 = 0;
while ((read2 = inputStream2.read(bufFile)) != -1) { fileOut.write(bufFile, 0, read2);
fileOut.flush(); } fileOut.close();
} catch (Exception e) {
// TODO: handle exception
}
} }

任意文件上传——tcp的更多相关文章

  1. WebLogic任意文件上传漏洞(CVE-2019-2618)

    WebLogic任意文件上传漏洞(CVE-2019-2618) 0x01 漏洞描述 漏洞介绍 CVE-2019-2618漏洞主要是利用了WebLogic组件中的DeploymentService接口, ...

  2. 【原创】JEECMS v6~v7任意文件上传漏洞(1)

    文章作者:rebeyond 受影响版本:v6~v7 漏洞说明: JEECMS是国内Java版开源网站内容管理系统(java cms.jsp cms)的简称.该系统基于java技术开发,继承其强大.稳定 ...

  3. 中国电信某站点JBOSS任意文件上传漏洞

    1.目标站点 http://125.69.112.239/login.jsp 2.简单测试 发现是jboss,HEAD请求头绕过失败,猜测弱口令失败,发现没有删除 http://125.69.112. ...

  4. Discuz!NT 后台任意文件上传的源代码修补方法

    相关的漏洞介绍: http://www.wooyun.org/bugs/wooyun-2013-035199 Discuz!NT 管理后台可以自定义文件类型,从而造成任意文件上传,测试过程中 aspx ...

  5. CKFinder 1.4.3 任意文件上传漏洞

    CKFinder 是国外一款非常流行的所见即所得文字编辑器,其1.4.3 asp.net版本存在任意文件上传漏洞,攻击者可以利用该漏洞上传任意文件. CKFinder在上传文件的时候,强制将文件名(不 ...

  6. WordPress Contact Form 7插件任意文件上传漏洞

    漏洞名称: WordPress Contact Form 7插件任意文件上传漏洞 CNNVD编号: CNNVD-201311-415 发布时间: 2013-11-28 更新时间: 2013-11-28 ...

  7. WordPress Suco Themes ‘themify-ajax.php’任意文件上传漏洞

    漏洞名称: WordPress Suco Themes ‘themify-ajax.php’任意文件上传漏洞 CNNVD编号: CNNVD-201311-403 发布时间: 2013-11-28 更新 ...

  8. WordPress Kernel Theme ‘upload-handler.php’任意文件上传漏洞

    漏洞名称: WordPress Kernel Theme ‘upload-handler.php’任意文件上传漏洞 CNNVD编号: CNNVD-201311-127 发布时间: 2013-11-12 ...

  9. WordPress Think Responsive Themes ‘upload_settings_image.php’任意文件上传漏洞

    漏洞名称: WordPress Think Responsive Themes ‘upload_settings_image.php’任意文件上传漏洞 CNNVD编号: CNNVD-201311-06 ...

随机推荐

  1. moviepy音视频剪辑:headblur的参数r_blur卷积核以及fx、fy、r_zone的功能作用及用途

    ☞ ░ 前往老猿Python博文目录 ░ 在moviepy1.03版本中,headblur的调用语法为:headblurbak(clip,fx,fy,r_zone,r_blur=None) 其中参数f ...

  2. PyQt(Python+Qt)学习随笔:QScrollArea的alignment属性不起作用的原因

    老猿Python博文目录 专栏:使用PyQt开发图形界面Python应用 老猿Python博客地址 Scroll Area滚动区域提供了一个呈现在其他部件上的可滚动区域视图,对应类为QScrollAr ...

  3. PyQt(Python+Qt)学习随笔:实现toolButton与Action的关联

    在Qt Designer中,如果创建的窗口为主窗口QMainWindow类型,可以通过<PyQt(Python+Qt)学习随笔:Qt Designer中怎么给toolBar添加按钮 >介绍 ...

  4. LeetCode初级算法之数组:48 旋转图像

    旋转图像 题目地址:https://leetcode-cn.com/problems/rotate-image/ 给定一个 n × n 的二维矩阵表示一个图像. 将图像顺时针旋转 90 度. 说明: ...

  5. 利用神经网络算法的C#手写数字识别(二)

    利用神经网络算法的C#手写数字识别(二)   本篇主要内容: 让项目编译通过,并能打开图片进行识别.   1. 从上一篇<利用神经网络算法的C#手写数字识别>中的源码地址下载源码与资源, ...

  6. 题解-Railgun

    题面 Railgun \(T\) 组测试数据,每次给定 \(n,k\),求(\(F(i)\) 为斐波那契数列第 \(i\) 项): \[\sum_{1\le x_i\le n(1\le i\le k) ...

  7. 抖音数据采集SDK

    接口参数.返回示例请参考文档:抖音api Github仓库:DouyinSDK 0. 初始化 from douyin import AwemeSDK token = 'xxxxxxxx' host = ...

  8. Vulnhub实战靶场:ME AND MY GIRLFRIEND: 1

    一.环境搭建 1.官网下载连接:https://www.vulnhub.com/entry/me-and-my-girlfriend-1,409/ 2.下载之后,使用Oracle VM Virtual ...

  9. STL——容器(Set & multiset)的默认构造 & 带参构造 & 对象的拷贝构造与赋值

    1. 默认构造 set<int> setInt;              //一个存放int的set容器. set<float> setFloat;          //一 ...

  10. 初入Nginx--配置篇

    Nginx的主配置文件为/path/to/nginx/nginx.conf.Nginx.conf的配置文件结构主要由以下几个部分组成: ..... events{ .... } http{ .... ...