Exemplo n.º 1
0
static void inject_user(void) 
{
   size_t len;

   /* escape the sequnces in the buffer */
   len = strescape((char*)injectbuf, (char*)injectbuf, strlen(injectbuf)+1);
   
   /* check where to inject */
   if (wdg_c1->flags & WDG_OBJ_FOCUSED) {
      user_inject(injectbuf, len, curr_conn, 1);
   } else if (wdg_c2->flags & WDG_OBJ_FOCUSED) {
      user_inject(injectbuf, len, curr_conn, 2);
   }
}
Exemplo n.º 2
0
/*
 * map the file into memory and pass the buffer to the inject function
 */
static void inject_file(const char *path, char *file)
{
   char *filename;
   int fd;
   void *buf;
   size_t size, ret;
   
   DEBUG_MSG("inject_file %s/%s", path, file);
   
   SAFE_CALLOC(filename, strlen(path)+strlen(file)+2, sizeof(char));

   snprintf(filename, strlen(path)+strlen(file)+2, "%s/%s", path, file);

   /* open the file */
   if ((fd = open(filename, O_RDONLY | O_BINARY)) == -1) {
      ui_error("Can't load the file");
      return;
   }
      
   SAFE_FREE(filename);

   /* calculate the size of the file */
   size = lseek(fd, 0, SEEK_END);
   
   /* load the file in memory */
   SAFE_CALLOC(buf, size, sizeof(char));
 
   /* rewind the pointer */
   lseek(fd, 0, SEEK_SET);
   
   ret = read(fd, buf, size);
   
   close(fd);

   if (ret != size) {
      ui_error("Cannot read the file into memory");
      return;
   }

   /* check where to inject */
   if (wdg_c1->flags & WDG_OBJ_FOCUSED) {
      user_inject(buf, size, curr_conn, 1);
   } else if (wdg_c2->flags & WDG_OBJ_FOCUSED) {
      user_inject(buf, size, curr_conn, 2);
   }

   SAFE_FREE(buf);
   
}
Exemplo n.º 3
0
static void gtkui_inject_user(int side)
{
   size_t len;
    
   /* escape the sequnces in the buffer */
   len = strescape(injectbuf, injectbuf);

   /* check where to inject */
   if (side == 1 || side == 2) {
      user_inject(injectbuf, len, curr_conn, side);
   }
}
Exemplo n.º 4
0
/*
 * map the file into memory and pass the buffer to the inject function
 */
static void gtkui_inject_file(char *filename, int side)
{
   int fd;
   void *buf;
   size_t size, ret;
   
   DEBUG_MSG("inject_file %s", filename);
   
   /* open the file */
   if ((fd = open(filename, O_RDONLY | O_BINARY)) == -1) {
      ui_error("Can't load the file");
      return;
   }
      
   /* calculate the size of the file */
   size = lseek(fd, 0, SEEK_END);
   
   /* load the file in memory */
   SAFE_CALLOC(buf, size, sizeof(char));
            
   /* rewind the pointer */
   lseek(fd, 0, SEEK_SET);
               
   ret = read(fd, buf, size);

   close(fd);

   if (ret != size) {
      ui_error("Cannot read the file into memory");
      return;
   }
      
   /* check where to inject */
   if (side == 1 || side == 2) {
      user_inject(buf, size, curr_conn, side);
   }

   SAFE_FREE(buf);
}