linux中的fake包是干吗用的

linux中的fake包是干吗用的,第1张

@desktop:~$ aptitude show fake

软件包: fake

状态: 未安装

版本号: 1.1.10-1

优先级: 可选

部分: universe/admin

维护者: Simon Horman <horms@debian.org>

未压缩尺寸: 164k

依赖于: libc6 (>= 2.3.2.ds1-4)

描述: IP address takeover tool

Fake is a utility that enables the IP address be taken over by bringing up a

second interface on the host machine and using gratuitous arp. Designed to

switch in backup servers on a LAN.

——————————

简单地说就是为了在局域网中备份主机的一个工具

个人电脑上没什么用吧

对的……

#include <gtk/gtk.h>

#include <gdk/gdkkeysyms.h>

#include <fakekey/fakekey.h>

#include <X11/keysym.h>

Display* disp

FakeKey *fk

GtkWidget *win = NULL

static char *numkeyboard_display[]=

{

  "1\0", "2\0", "3\0", "+","4\0", "5\0", "6\0","-", "7\0", "8\0", "9\0", ".", "0\0",  "←\0", "→\0", "Backspace\0", "Delete\0", "Enter\0"

}

static gushort numkeyboard_send[] =

{

  XK_1, XK_2, XK_3, XK_plus, XK_4, XK_5, XK_6, XK_minus, XK_7, XK_8,  XK_9, XK_period, XK_0,  XK_Left, XK_Right, XK_BackSpace, XK_Delete, XK_Return

}

gboolean numbt_release (GtkWidget *widget, GdkEventButton *event,

      gpointer user_data)

{

  gint i = GPOINTER_TO_UINT(user_data)

  fakekey_press_keysym(fk, numkeyboard_send[i], 0)

  fakekey_release(fk)

  return TRUE

}

void clicked_callback(GtkButton *button1, GtkWindow *window)

{

  gint j

  GtkWidget *button[5]

  GtkWidget *vbox = gtk_vbox_new(FALSE, 5)

  GtkWidget *hbox[5]

  if(win)

  {

      gtk_widget_destroy (win)

      win = NULL

  }

  else

  {

      win = gtk_window_new (GTK_WINDOW_POPUP)

      hbox[0] = gtk_hbox_new(TRUE, 5)

      for (j = 0 j <4j++ ) {

          button[0] = gtk_button_new_with_label (numkeyboard_display[j])

          gtk_box_pack_start_defaults(GTK_BOX(hbox[0]), button[0])

          g_signal_connect(G_OBJECT(button[0]), "button-release-event",

                  G_CALLBACK(numbt_release), GUINT_TO_POINTER (j))

      }

      gtk_box_pack_start_defaults(GTK_BOX(vbox), hbox[0])

      hbox[1] = gtk_hbox_new(TRUE, 5)

      for (j = 4 j <8j++ ) {

          button[1] = gtk_button_new_with_label (numkeyboard_display[j])

          gtk_box_pack_start_defaults(GTK_BOX(hbox[1]), button[1])

          g_signal_connect(G_OBJECT(button[1]), "button-release-event",

                  G_CALLBACK(numbt_release), GUINT_TO_POINTER (j))

      }

      gtk_box_pack_start_defaults(GTK_BOX(vbox), hbox[1])

      hbox[2] = gtk_hbox_new(TRUE, 5)

      for (j = 8 j <12j++ ) {

          button[2] = gtk_button_new_with_label (numkeyboard_display[j])

          gtk_box_pack_start_defaults(GTK_BOX(hbox[2]), button[2])

          g_signal_connect(G_OBJECT(button[2]), "button-release-event",

                  G_CALLBACK(numbt_release), GUINT_TO_POINTER (j))

      }

      gtk_box_pack_start_defaults(GTK_BOX(vbox), hbox[2])

      hbox[3] = gtk_hbox_new(TRUE, 5)

      for (j = 12 j <15j++ ) {

          button[3] = gtk_button_new_with_label (numkeyboard_display[j])

          gtk_box_pack_start_defaults(GTK_BOX(hbox[3]), button[3])

          g_signal_connect(G_OBJECT(button[3]), "button-release-event",

                  G_CALLBACK(numbt_release), GUINT_TO_POINTER (j))

      }

      gtk_box_pack_start_defaults(GTK_BOX(vbox), hbox[3])

      hbox[4] = gtk_hbox_new(TRUE, 5)

      for (j = 15 j <18j++ ) {

          button[4] = gtk_button_new_with_label (numkeyboard_display[j])

          gtk_box_pack_start_defaults(GTK_BOX(hbox[4]), button[4])

          g_signal_connect(G_OBJECT(button[4]), "button-release-event",

                  G_CALLBACK(numbt_release), GUINT_TO_POINTER (j))

      }

      gtk_box_pack_start_defaults(GTK_BOX(vbox), hbox[4])

      gtk_container_add(GTK_CONTAINER(win), vbox)

      gtk_window_move (GTK_WINDOW (win), 200, 200)/* 设置窗口位置 */

      gtk_widget_show_all(win)

   

  }

}

int main(int argc, char *argv[])

{

   GtkWidget *window

   GtkWidget *button

   GtkWidget *entry

   GtkWidget *vbox

   gtk_init(&argc, &argv)

   window = gtk_window_new(GTK_WINDOW_TOPLEVEL)

   gtk_window_set_title(GTK_WINDOW(window), "KeyBoard")

   gtk_window_set_default_size(GTK_WINDOW(window),400,300)

   disp = XOpenDisplay(NULL)//屏幕按键函数改成为内核驱动代发

   if( disp == NULL )

       return 1

   fk = fakekey_init(disp)

   vbox = gtk_vbox_new(FALSE, 5)

   button = gtk_button_new_with_label("d出键盘")

   gtk_widget_set_size_request(GTK_WIDGET(button),400,250)

   gtk_box_pack_start_defaults(GTK_BOX(vbox), button)

   entry = gtk_entry_new()

   gtk_box_pack_start_defaults(GTK_BOX(vbox), entry)

   gtk_widget_set_size_request(GTK_WIDGET(entry),400,50)

   g_signal_connect(GTK_OBJECT(window), "destroy",G_CALLBACK(gtk_main_quit), NULL)

   g_signal_connect(GTK_OBJECT(button), "clicked",G_CALLBACK(clicked_callback), window)

   gtk_container_add(GTK_CONTAINER(window), vbox)

   gtk_widget_show_all(window)

   gtk_main()

   return 0

}


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/7110141.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-01
下一篇 2023-04-01

发表评论

登录后才能评论

评论列表(0条)

保存