Advertisement
Guest User

Untitled

a guest
Nov 7th, 2018
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.43 KB | None | 0 0
  1. // Eikon.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "bsapi.h"
  6. #include <stdlib.h>
  7. #include "C:\Users\Tadas\Desktop\magistrantura\Informaciniu technologiju sauga\I lab\1lab\Eikon\Eikon\\dirent.h"
  8. #include <string.h>
  9.  
  10.  
  11. /* Used to supress compiler warnings */
  12. #ifndef UNREFERENCED_PARAMETER
  13. #define UNREFERENCED_PARAMETER(param) (void)param
  14. #endif
  15.  
  16. //Pirstu sablonu kiekis
  17. #define TSET_SIZE 16
  18. int sablonu_kiekis;
  19.  
  20. //Sesijos kintamasis su irenginiu
  21. static ABS_CONNECTION conn = 0;
  22.  
  23. //Sablonu nuorodu masyvas
  24. static ABS_BIR* tset[TSET_SIZE];
  25.  
  26. //Operacijos "callback" funkcija
  27. static void BSAPI
  28. callback(const ABS_OPERATION* p_operation, ABS_DWORD msg, void* data)
  29. {
  30. UNREFERENCED_PARAMETER(p_operation);
  31.  
  32. switch (msg) {
  33. /* These messages just inform us how the interactive operation
  34. * progresses. Typical applications do not need it. */
  35. case ABS_MSG_PROCESS_BEGIN:
  36. case ABS_MSG_PROCESS_END:
  37. break;
  38.  
  39. /* On some platforms, the biometric operastion can be suspended
  40. * when other process acquires sensor for other operation. */
  41. case ABS_MSG_PROCESS_SUSPEND:
  42. printf(" operation has been suspended\n");
  43. break;
  44. case ABS_MSG_PROCESS_RESUME:
  45. printf(" operation has been resumed\n");
  46. break;
  47.  
  48. /* Sometimes some info how the operation progresses is sent. */
  49. case ABS_MSG_PROCESS_PROGRESS:
  50. {
  51. ABS_PROCESS_PROGRESS_DATA* progress_data =
  52. (ABS_PROCESS_PROGRESS_DATA*)data;
  53. if (progress_data->Percentage <= 100) {
  54. printf(" operation in progress (%d%%)...\n",
  55. (int)progress_data->Percentage);
  56. }
  57. else {
  58. printf(" operation in progress...\n");
  59. }
  60. break;
  61. }
  62. case ABS_MSG_PROCESS_SUCCESS:
  63. printf(" success\n");
  64. break;
  65. case ABS_MSG_PROCESS_FAILURE:
  66. printf(" failure\n");
  67. break;
  68.  
  69. /* Prompt messages should inform the user that he should do
  70. * something. */
  71. case ABS_MSG_PROMPT_SCAN:
  72. printf(" swipe the finger\n");
  73. break;
  74. case ABS_MSG_PROMPT_TOUCH:
  75. printf(" touch the sensor\n");
  76. break;
  77. case ABS_MSG_PROMPT_KEEP:
  78. printf(" keep finger on the sensor\n");
  79. break;
  80. case ABS_MSG_PROMPT_LIFT:
  81. printf(" lift your finger away from the sensor\n");
  82. break;
  83. case ABS_MSG_PROMPT_CLEAN:
  84. printf(" clean the sensor\n");
  85. break;
  86.  
  87. /* Quality messages come if something went wrong. E.g. the user
  88. * did not scan his finger in the right way. */
  89. case ABS_MSG_QUALITY_CENTER_HARDER:
  90. printf(" bad quality: center and harder\n");
  91. break;
  92. case ABS_MSG_QUALITY_CENTER:
  93. printf(" bad quality: center\n");
  94. break;
  95. case ABS_MSG_QUALITY_TOO_LEFT:
  96. printf(" bad quality: too left\n");
  97. break;
  98. case ABS_MSG_QUALITY_TOO_RIGHT:
  99. printf(" bad quality: too right\n");
  100. break;
  101. case ABS_MSG_QUALITY_HARDER:
  102. printf(" bad quality: harder\n");
  103. break;
  104. case ABS_MSG_QUALITY_TOO_LIGHT:
  105. printf(" bad quality: too light\n");
  106. break;
  107. case ABS_MSG_QUALITY_TOO_DRY:
  108. printf(" bad quality: too dry\n");
  109. break;
  110. case ABS_MSG_QUALITY_TOO_SMALL:
  111. printf(" bad quality: too small\n");
  112. break;
  113. case ABS_MSG_QUALITY_TOO_SHORT:
  114. printf(" bad quality: too short\n");
  115. break;
  116. case ABS_MSG_QUALITY_TOO_HIGH:
  117. printf(" bad quality: too high\n");
  118. break;
  119. case ABS_MSG_QUALITY_TOO_LOW:
  120. printf(" bad quality: too low\n");
  121. break;
  122. case ABS_MSG_QUALITY_TOO_FAST:
  123. printf(" bad quality: too fast\n");
  124. break;
  125. case ABS_MSG_QUALITY_TOO_SKEWED:
  126. printf(" bad quality: too skewed\n");
  127. break;
  128. case ABS_MSG_QUALITY_TOO_DARK:
  129. printf(" bad quality: too dark\n");
  130. break;
  131. case ABS_MSG_QUALITY_BACKWARD:
  132. printf(" bad quality: backward movement detected\n");
  133. break;
  134. case ABS_MSG_QUALITY_JOINT:
  135. printf(" bad quality: joint detected\n");
  136. break;
  137.  
  138. /* Navigation messages are sent only from ABSNavigate */
  139. case ABS_MSG_NAVIGATE_CHANGE:
  140. {
  141. ABS_NAVIGATION_DATA* msgdata = (ABS_NAVIGATION_DATA*)data;
  142. printf(" Navigation X = %d, Y = %d\n", (int)msgdata->DeltaX, (int)msgdata->DeltaY);
  143. break;
  144. }
  145. case ABS_MSG_NAVIGATE_CLICK:
  146. printf(" Navigation - CLICK\n");
  147. break;
  148.  
  149. /* Real application would probably use some GUI to provide feedback
  150. * for user. On these messages the GUI dialog should be made vsiible
  151. * and invisible respectivelly. */
  152. case ABS_MSG_DLG_SHOW:
  153. case ABS_MSG_DLG_HIDE:
  154. break;
  155.  
  156. /* Idle message can come only if flag ABS_OPERATION_FLAG_USE_IDLE
  157. * was specified in ABS_OPERATION::dwFlags (i.e. never in this sample).
  158. * If the flag is specified, this message comes very often, hence
  159. * giving the callback a chance to cancel the operation with
  160. * ABSCancelOperation() without long time delays. In multithreaded
  161. * applications, canceling the operation from another thread can be
  162. * better alternative. Consult BSAPI documentation for more info about
  163. * the topic. */
  164. case ABS_MSG_IDLE:
  165. break;
  166. }
  167. }
  168.  
  169. static ABS_OPERATION op = {
  170. /* ID of the operation. We don't need to identify the operation in this
  171. * sample. When non-zero, the ID identifies the operation and allows it
  172. * to be canceled from any other thread with ABSCancelOperation(). */
  173. 0,
  174.  
  175. /* Arbitrary pointer, which allows application to pass any data into
  176. * the callback. Not used in this sample. */
  177. NULL,
  178.  
  179. /* Pointer to a simple callback implementation function. */
  180. callback,
  181.  
  182. /* Timeout. For example, lets set timeout to 60 sec. Note the value does
  183. * not limit how long the operation (e.g. ABSVerify()) can take. The
  184. * timeout only specifies time the operation waits for user to put his
  185. * finger on a sensor. Zero would mean no timeout (i.e. the operation can
  186. * never end if user never puts his finger on the sensor.) */
  187. 60000,
  188.  
  189. /* By default BSAPI places short time delays between sending some important
  190. * callback messages. The purpose of this is to guarantee that if multiple
  191. * messages come very closely in sequence, then the user still has enough
  192. * time to see all the messages and not just the lat one of the fast
  193. * sequence.
  194. *
  195. * For application developer, this simplifies callback implementation
  196. * which in most cases can be just showing an appropriate message in a
  197. * window or dialog.
  198. *
  199. * However the time delays are not needed when user can see all history
  200. * of the messages, e.g. (as in this sample) the messages are outputted
  201. * to standard output stream. Hence we disable the time delays with with
  202. * the flag ABS_OPERATION_FLAG_LL_CALLBACK here. */
  203. ABS_OPERATION_FLAG_LL_CALLBACK
  204. };
  205.  
  206. static void klaida(void)
  207. {
  208. printf("KLAIDA\n");
  209. }
  210.  
  211. // 5.4
  212. static void nauja_sesija(void)
  213. {
  214. //sukuriam nauja sesija su skaitytuvu
  215. ABS_STATUS res;
  216. res = ABSOpen("usb", &conn);
  217. if (res == ABS_STATUS_OK)
  218. {
  219. printf("Sukurta nauja sesija\n");
  220. }
  221. else
  222. {
  223. klaida();
  224. }
  225. }
  226.  
  227.  
  228. static int tikrinimas(void) {
  229. printf("tikrinam...\n");
  230. ABS_BIR * tmp_tset = NULL;
  231. ABS_STATUS res = ABSEnroll(conn, &op, &tmp_tset, 0);
  232. ABS_BOOL match;
  233. int rasta = 0;
  234. if (res == ABS_STATUS_OK)
  235. {
  236. //anspaudas sekmingai nuskaitytas galima toliau atlikti veiksmus
  237. for (int i = 0; i < sablonu_kiekis; i++) {
  238. res = ABSVerifyMatch(conn, tmp_tset, tset[i], &match, 0);
  239. if (match) {
  240. rasta = 1;
  241. break;
  242. }
  243. }
  244. }
  245. else
  246. {
  247. klaida();
  248. return 1;
  249. }
  250. if (rasta == 0)
  251. {
  252. printf("Pirstas nerastas!\n");
  253. return 1;
  254. }
  255. else {
  256. printf("Pirstas rastas...\n");
  257. return 0;
  258. }
  259. }
  260.  
  261.  
  262. static void siusti_zinute(char *tekstas, char *url, char *nr) {
  263. char text[500];
  264. snprintf(text, 500, "C:\\Users\\Tadas\\Desktop\\curl\\curl.exe \"http://%s&number=%s&text=%s\"", url, nr, tekstas);
  265. system(text);
  266. printf("Zinute issiusta! Zinutes tekstas: %s\n", tekstas);
  267. }
  268.  
  269.  
  270. static void failo_uzkrovimas(void)
  271. {
  272. int slot = 0;
  273. char path[300];
  274. DIR *dir;
  275. struct dirent *ent;
  276. FILE *f;
  277.  
  278. if ((dir = opendir("D:\\sablonai")) != NULL) {
  279. while ((ent = readdir(dir)) != NULL) {
  280. if (strcmp(".", ent->d_name) == 0 || strcmp("..", ent->d_name) == 0)
  281. continue;
  282. sprintf_s(path, "D:\\sablonai\\%s", ent->d_name);
  283. f = fopen(path, "rb");
  284. fseek(f, 0, SEEK_END); // seek to end of file
  285. int size = ftell(f); // get current file pointer
  286. printf("Failo dydis: %d\n", size);
  287. fseek(f, 0, SEEK_SET); // seek back to beginning of file
  288. // proceed with allocating memory and reading the file
  289. tset[slot] = (ABS_BIR*)malloc(size);
  290. printf("KINTAMOJO TIKRINIMAS: %d\n", tset[slot]);
  291. if (tset[slot] == NULL) {
  292. printf("Negaliu issiskirti %ld baitu atminties\n", size);
  293. fclose(f);
  294. return;
  295. }
  296. if (fread(tset[slot], size, 1, f) != 1) {
  297. printf("Negaliu nuskaityti %ld baitu is failo '%s'\n", size, "D:\\sablonai\\sablonas.txt");
  298. free(tset[slot]);
  299. tset[slot] = NULL;
  300. fclose(f);
  301. return;
  302. }
  303.  
  304. //nuskaitau faila i tset sablonu nuorodu masyva
  305. fread(tset[slot], size, 1, f);
  306. fclose(f);
  307. slot++;
  308. }
  309. }
  310. sablonu_kiekis = slot + 1;
  311. return;
  312. }
  313.  
  314. static void pagalba(void)
  315. {
  316. printf("Komandas sarasas:\n");
  317. printf("'h ... Pagalba\n");
  318. printf(" x ... Iseiti\n");
  319. printf(" s ... Sukuriama nauja sesija su irenginiu\n");
  320. printf(" n ... Sukuriamas naujas pirsto antspaudo sablonas SLOT1 ir issaugojamas masyve\n");
  321. printf(" m ... Sukuriamas naujas pirsto antspaudo sablonas SLOT2 ir issaugojamas masyve\n");
  322. printf(" l ... Palyginamas naujas pirsto atspaudas su SLOT1 sablonu\n");
  323. printf(" o ... Palyginamas naujas pirsto atspaudas su visais pirstu antspaudu sablonais\n");
  324. printf(" c ... Atliekamas palyginimas tarp irasytu sablonu SLOT1 ir SLOT2\n");
  325. }
  326.  
  327. int _tmain(int argc, _TCHAR* argv[])
  328. {
  329. char buffer[256];
  330. ABS_STATUS res;
  331. int baigti = 0;
  332.  
  333. //Pries kvieciant kitas funkcijas, turim inicializuoti BSAPI biblioteka
  334. res = ABSInitialize();
  335.  
  336. if (res == ABS_STATUS_OK) {
  337. printf("Inicializavom BSAPI\n\n");
  338. }
  339.  
  340. //pagalba();
  341. nauja_sesija();
  342. failo_uzkrovimas();
  343. while (1) {
  344. if (tikrinimas() != 0) {
  345. siusti_zinute("Nesekmingas bandymas", "192.168.1.1/cgi-bin/sms_send?username=admin&password=Kaunastlt1!", "+37063729704");
  346. siusti_zinute("Nesekmingas bandymas", "192.168.1.1/cgi-bin/sms_send?username=admin&password=Kaunastlt1!", "+37063977973");
  347. //siunciam sms
  348. }
  349. else {
  350. //viskas gerai
  351. siusti_zinute("Sekmingas bandymas", "192.168.1.1/cgi-bin/sms_send?username=admin&password=Kaunastlt1!", "+37063729704");
  352. siusti_zinute("Sekmingas bandymas", "192.168.1.1/cgi-bin/sms_send?username=admin&password=Kaunastlt1!", "+37063977973");
  353. }
  354. }
  355. ABSTerminate();
  356.  
  357. return 0;
  358. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement