Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/external/source/ipwn/cmd_sys.c
Views: 11766
/*1* Copyright (c) 2004-2005 vlad902 <vlad902 [at] gmail.com>2* This file is part of the Metasploit Framework.3* $Revision$4*/56#include <sys/types.h>7#include <stdlib.h>8#include <unistd.h>9#include <string.h>10#include <errno.h>11#include <stdio.h>12#include <time.h>13#include <sys/utsname.h>14#ifdef SYSCALL_REBOOT15#include <linux/reboot.h>1617#define reboot(arg) reboot(0xfee1dead, 0x28121969, arg, NULL)18#else19#include <sys/reboot.h>20#endif2122#include "cmd.h"232425void cmd_time(int argc, char * argv[])26{27printf("%s\n", get_time_str("%a %b %d %H:%M:%S %Z %Y"));28}2930void cmd_uname(int argc, char * argv[])31{32struct utsname info;3334if(uname(&info) == -1)35perror("uname");36else37printf("%s %s %s %s %s\n", info.sysname, info.nodename, \38info.release, info.version, info.machine);39}4041void cmd_hostname(int argc, char * argv[])42{43/* This should be big enough to accomodate all cases. */44char buf[8192];4546if(argc > 1)47{48if(sethostname(argv[1], strlen(argv[1])) == -1)49perror("sethostname");50}51else52{53if(gethostname(buf, sizeof(buf)) == -1)54perror("gethostname");55else56printf("%s\n", buf);57}58}5960void cmd_reboot(int argc, char * argv[])61{62sync();6364if(reboot(0x01234567) == -1)65perror("reboot");66}6768/* Linux >= 2.1.30 */69void cmd_shutdown(int argc, char * argv[])70{71sync();7273if(reboot(0x4321fedc) == -1)74perror("shutdown");75}7677/* Linux >= 1.1.76 */78void cmd_halt(int argc, char * argv[])79{80sync();8182if(reboot(0xcdef0123) == -1)83perror("halt");84}858687