linux下的端口扫描技术!
这个是我在一本书上看到的,其中的一些代码我有所改变,写给各位好友共享一下!
#include <sys/types.h>
#include <sys/socket.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <errno.h>
#include "my_recv.h" // 自定义的头文件
#define SERV_PORT 4507 // 服务器端的端口
#define LISTENQ 12 // 连接请求队列的最大长度
#define INVALID_USERINFO 'n' // 用户信息无效
#define VALID_USERINFO 'y' // 用户信息有效
#define USERNAME 0 // 接收到的是用户名
#define PASSWORD 1 // 接收到的是密码
struct userinfo { // 保存用户名和密码的结构体
char username[32];
char password[32];
};
struct userinfo users[ ] = {
{"linux", "unix"},
{"4507", "4508"},
{"clh", "clh"},
{"xl", "xl"},
{" "," "} // 以只含一个空格的字符串作为数组的结束标志
};
// 查找用户名是否存在,存在返回该用户名的下标,不存在则返回-1,出错返回-2
int find_name(const char *name)
{
int i;
if (name == NULL) {
printf("in find_name, NULL pointer");
return -2;
}
for (i=0; users[i].username[0] != ' ';i++) {
if (strcmp(users[i].username, name) == 0) {
return i;
}
}
return -1;
}
// 发送数据
void send_data(int conn_fd, const char *string)
{
if (send(conn_fd, string, strlen(string), 0) < 0) {
my_err("send", __LINE__); // my_err函数在my_recv.h中声明
}
}
int main()
{
int sock_fd, conn_fd;
int optval;
int flag_recv = USERNAME; // 标识接收到的是用户还是密码
int ret;
int name_num;
pid_t pid;
socklen_t&
相关文档:
一、登陆
1.进入linux
2.用户名: root
3.口令:123456
4.mysql 用户名 root 密码 123456
二、启动mysql与apache服务
1.启动mysq数据库:/usr/local/mysql/bin/./mysqld_safe --user=mysql &
2.停止mysql数据库:/usr/local/mysql/bin/mysqladmin -u root -p shutdown
3.启动apache: /usr/local/apache2/bin/./ap ......
1、简单的查找并替换为新的字符串
:%s/查找的字符串/新的字符串/g
eg:查找“liliang” 并将其替换为“liangli”
:%s/liliang/liangli/g
其中“\”为转义符
eg:查找“li/liang” 并将其替换为“liliang”(即把被查找字符串中的斜杠去掉)
:%s/li\/liang/liliang ......
虽然目前Linux的优势主要体现在网络服务方面,但事实上同样也有着非常丰富的媒体功能,本文就是以多媒体应用中最基本的声音为对象,介绍如何在Linux平台下开发实际的音频应用程序,同时还给出了一些常用的音频编程框架。
一、数字音频
音频信号是一种连续变化的模拟信号,但计算机只能处理和记录二进制的数字信号,由自然 ......
转至: http://dev.yesky.com/412/2639912.shtml
对于提供了MMU(存储管理器,辅助操作系统进行内存管理,提供虚实地址转换等硬件支持)的处理器而言,Linux提供了复杂的存储管理系统,使得进程所能访问的内存达到4GB。
进程的4GB内存空间被人为的分为两个部分--用户空间与内核空间。用户空间地址分布从0到3GB(P ......
这是在实验室搭建局域网时的配置写在这里吧,等在回忆那段大学生活时还是很美好的!
环境:外网IP 202.206.249.186 子网掩码 255.255.255.0 默认网关 202.206.249.1
内网IP192.168.0.1 子网掩码 255 ......