79.cgi硬盘查询个人信息
运行截图:

- 把cgi编码转为char*类型
//把cgi编码转为char*类型
char* change(char *str)
{
//分配内存
char *tempstr = malloc(strlen(str) + ); //x是tempstr的下标,y是str的下标
int x = , y = ;
char assii_1, assii_2;
while (str[y])
{
if ((tempstr[x] = str[y]) == '%')
{
//获取第一个字符
if (str[y + ] >= 'A')
{
assii_1 = str[y + ] - ; }
else
{
assii_1 = str[y + ] - ;
}
//获取第二个字符
if (str[y + ] >= 'A')
{
assii_2 = str[y + ] - ;
}
else
{
assii_2 = str[y + ] - ;
}
tempstr[x] = assii_1 * + assii_2; y += ; }
x++;
y++;
}
//最后一位置零
tempstr[x] = '\0';
return tempstr;
} - 查询
//查询
void showlist(char str[])
{ printf("%s%s\n", str,str);
//文件指针
FILE *pf;
//读取
pf = fopen(strpath, "r"); if (pf == NULL)
{
printf("文件打开失败");
}
else
{
//没有到文件末尾就继续
while (!feof(pf))
{
char readstr[] = { };
//读取一行
fgets(readstr, , pf);
//字符串查找
char *p = strstr(readstr, str);
if (p != NULL)
{
//输出到网页
//puts(readstr);
printf("%s",readstr);
puts("<br>");
}
}
fclose(pf);
}
} - 主函数
printf("Content-type:text/html\n\n");//换行 //等待一下
system("mkdir 1");
//获取表单的数据到szpost中 格式 cmd1=%BD%C8&cmd2=abc
char szpost[] = { };
gets(szpost);
printf("%s", szpost); //找到第一个输入框的内容
char*p1 = strchr(szpost, '&');
if (p1 != NULL)
{
*p1 = '\0';
}
//输出相应的信息
printf("<br>%s", szpost + );
//cgi编码格式转换为char*类型
printf("<br>%s", change(szpost + )); //获取第二个输入框的内容
char *p2 = strchr(p1 + , '&');
if (p2 != NULL)
{
*p2 = '\0';
}
printf("<br>%s", p1 + );
printf("<br>%s", change(p1 + )); //查询
showlist(change(szpost + ));
完整代码
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include <string.h> //把cgi编码转为char*类型
char* change(char *str)
{
//分配内存
char *tempstr = malloc(strlen(str) + ); //x是tempstr的下标,y是str的下标
int x = , y = ;
char assii_1, assii_2;
while (str[y])
{
if ((tempstr[x] = str[y]) == '%')
{
//获取第一个字符
if (str[y + ] >= 'A')
{
assii_1 = str[y + ] - ; }
else
{
assii_1 = str[y + ] - ;
}
//获取第二个字符
if (str[y + ] >= 'A')
{
assii_2 = str[y + ] - ;
}
else
{
assii_2 = str[y + ] - ;
}
tempstr[x] = assii_1 * + assii_2; y += ; }
x++;
y++;
}
//最后一位置零
tempstr[x] = '\0';
return tempstr;
} //定义路径
char strpath[] = "kaifang.txt"; //查询
void showlist(char str[])
{ printf("%s%s\n", str,str);
//文件指针
FILE *pf;
//读取
pf = fopen(strpath, "r"); if (pf == NULL)
{
printf("文件打开失败");
}
else
{
//没有到文件末尾就继续
while (!feof(pf))
{
char readstr[] = { };
//读取一行
fgets(readstr, , pf);
//字符串查找
char *p = strstr(readstr, str);
if (p != NULL)
{
//输出到网页
//puts(readstr);
printf("%s",readstr);
puts("<br>");
}
}
fclose(pf);
}
} void main()
{
printf("Content-type:text/html\n\n");//换行 //等待一下
system("mkdir 1");
//获取表单的数据到szpost中 格式 cmd1=%BD%C8&cmd2=abc
char szpost[] = { };
gets(szpost);
printf("%s", szpost); //找到第一个输入框的内容
char*p1 = strchr(szpost, '&');
if (p1 != NULL)
{
*p1 = '\0';
}
//输出相应的信息
printf("<br>%s", szpost + );
//cgi编码格式转换为char*类型
printf("<br>%s", change(szpost + )); //获取第二个输入框的内容
char *p2 = strchr(p1 + , '&');
if (p2 != NULL)
{
*p2 = '\0';
}
printf("<br>%s", p1 + );
printf("<br>%s", change(p1 + )); //查询
showlist(change(szpost + ));
}
79.cgi硬盘查询个人信息的更多相关文章
- WMI技术介绍和应用——查询硬件信息
//查询得到系统盘所在硬盘的ID SELECT DiskIndex FROM Win32_DiskPartition WHERE Bootable = TRUE //如何使用WMI查询系统盘所在硬盘的 ...
- 实战DeviceIoControl 之四:获取硬盘的详细信息
Q 用IOCTL_DISK_GET_DRIVE_GEOMETRY或IOCTL_STORAGE_GET_MEDIA_TYPES_EX只能得到很少的磁盘参数,我想获得包括硬盘序列号在内的更加详细的信息,有 ...
- bat命令查询硬件信息
bat命令查询硬件信息 50 需求是这样的写一个bat命令,当命令执行的时候,先请用户输入姓名,然后继续执行查询出以下信息并写入一个文件,文件名称随便,文件可以放在与当前命令同一个文件夹下.最终文件中 ...
- 实战DeviceIoControl系列之四:获取硬盘的详细信息
Q 用IOCTL_DISK_GET_DRIVE_GEOMETRY IOCTL_STORAGE_GET_MEDIA_TYPES_EX只能得到很少的磁盘参数,我想获得包括硬盘序列号在内的更加详细的信息,有 ...
- SQL Server2016 新功能实时查询统计信息
SQL Server2016 新功能实时查询统计信息 很多时候有这样的场景,开发抱怨DBA没有调优好数据库,DBA抱怨开发写的程序代码差,因此,DBA和开发都成为了死对头,无法真正排查问题. DBA只 ...
- 16进制ascii码转化为对应的字符,付ipmitool查询硬件信息
最近工作需要在用ipmitool查询服务器硬件信息.ipmitool查询硬件信息 比如电源,使用命令: 获取PSU0信息:Ipmitool raw 0x3a 0x71 0x00: 获取PSU1信息:I ...
- 【Gerrit】Gerrit cmd query (gerrit命令行查询change信息)
本文仅展现个人使用情况和理解,英文原址:https://review.openstack.org/Documentation/cmd-query.html 基本使用格式: ssh -p <por ...
- Asp.Net MVC4入门指南(9):查询详细信息和删除记录
在本教程中,您将查看自动生成的Details和Delete方法. 查询详细信息和删除记录 打开Movie控制器并查看Details方法. public ActionResult Details(int ...
- SQL查询数据库信息, 数据库表名, 数据库表信息
SQL查询数据库信息, 数据库表名, 数据库表信息 ---------------------------------------------- -- 以下例子, 在sql_server 中可以直接运 ...
随机推荐
- netflix feign概述
1.什么是feign?feign的作用是什么? Feign is a java to http client binder inspired by Retrofit, JAXRS-2.0, and W ...
- android学习笔记五。2、其他组件
一.ContentProvider内容提供者.是是android中一个应用向第三方共享数据的方式,android中的联系人,sms(短信记录)等都是通过这一方式来向外提供的 1.使用: 在应用中使用C ...
- [ Java ][ Eclipse ] 停止讓 Eclipse 跳出 Password Required
stackoverflow 上,問題的解決方式: http://stackoverflow.com/questions/4713890/how-to-disable-programmatically- ...
- Codefroces432 div2 A,B,C
A. Arpa and a research in Mexican wave Arpa is researching the Mexican wave. There are n spectators ...
- Important Abstractions and Data Structures
For Developers > Coding Style > Important Abstractions and Data Structures 目录 1 TaskRunne ...
- Reference Counting GC (Part one)
目录 引用计数法 计数器值的增减 new_obj()和update_ptr()函数 new_obj()生成对象 update_ptr()更新指针ptr,对计数器进行增减 优点 可即可回收垃圾 最大暂停 ...
- JQ each 各种标签
类选择器: $("input[class=class1]").each(function(){ alert($(this).val()); }); ID选择器: $("i ...
- C# Excel文件导入操作
Excel文件导出的操作我们经经常使用到,可是讲一个Excel文档导入并显示到界面还是第一次用到. 以下简介下在C#下怎样进行Excel文件的导入操作. 首先加入两个引用 using System.I ...
- [Servlet]研究ServletContext对象
作者信息 作者姓名:金云龙 个人站点:http://www.longestory.com 个人公众帐号:搜索"longestory"或"龙哥有话说" Servl ...
- solr 亿万级数据查询性能測试
废话不多说,我电脑配置 i7四核cpu 8G内存 插入数据文档中有5个字段,当中有两个分词.一个int,一个date 批量插入測试一次10万循环10次总共100万用时85秒 批量插入測试一次10万循环 ...