int print_access(string bit, mapping bing, int depth, int cols) { mixed *bits; int i; if (this_player() != this_player(1)) return 0; bits = m_indices(bing); if (depth == 4) { /* Do the ident printing... */ for (i=0;i<sizeof(bits);i++) switch (bing[bits[i]]) { case NO_NEW : printf("%s@%-=*s", bits[i], cols - strlen(bits[i]), bit + " set to no new characters.\n"); break; case NO_ACCESS : printf("%s@%-=*s", bits[i], cols - strlen(bits[i]), bit + " set to no characters.\n"); break; case ACCESS : printf("%s@%-=*s", bits[i], cols - strlen(bits[i]), bit + " set to normal access.\n"); break; } return 1; } for (i=0;i<sizeof(bits);i++) print_access(bit+"."+bits[i], bing[bits[i]], depth+1, cols); return 1; } /* print_access() */
//main function for running program int main() { bool is_permission = false; int attempt_number = 1; char password[] = PASSWORD; char password_attempt[100]; print_intro(); //password attempt loop do { print_security_level(attempt_number); scanf("%99s", password_attempt); is_permission = check_password(password, password_attempt); //print cases for password attempt if(is_permission == false && attempt_number == MAX_ATTEMPT) { print_password_denied(attempt_number, MAX_ATTEMPT); system("qlmanage -p ./data/ned.gif"); animate(); } else if(is_permission == true) print_access(); else { print_password_denied(attempt_number, MAX_ATTEMPT); attempt_number++; } }while(is_permission == false); return 0; }
void Class::printField() { for(int i=0;i<fields_count; i++) { printf("[%d] ", i); print_access(get_field_flags(i)); printf("%s:", get_field_name(i)); printf("%s\n", get_field_type(i)); } }
int do_access() { mixed bing; if (this_player() != this_player(1)) return 0; bing = (mixed)"/secure/bastards"->query_all_access(); if (!m_sizeof(bing)) { notify_fail("No access control defined.\n"); return 0; } print_access("", bing, 0, (int)this_player()->query_cols()); return 1; } /* do_access() */
std::string file_base::get_info() { std::string res; if (mod.type == file_type::file) res += '-'; if (mod.type == file_type::folder) res += 'd'; //access res += print_access(mod.owner) + print_access(mod.group) + print_access(mod.other); //owner char tmp[10]; sprintf(tmp, "%6s", owner.c_str()); res += " " + std::string(tmp); //time char tmpBuf[200]; strftime(tmpBuf, 200, "%Y/%m/%d %H:%M", localtime(&time_modified)); res += " " + std::string(tmpBuf); // res += " " + file_name; return res; }
int main(int argc, char *argv[]) { struct dazuko_access *acc; int args_ok = 0; int i; struct dazuko_version ver; if (dazukoIOVersion(&ver) != 0) { printf("error: failed to read DazukoIO version\n"); return -1; } printf("DazukoIO version %s (%d.%d.%d.%d)\n", ver.text, ver.major, ver.minor, ver.revision, ver.release); /* register with dazuko */ if (dazukoRegister("DAZUKO_EXAMPLE", "r+") != 0) { printf("error: failed to register with Dazuko\n"); return -1; } printf("registered with Dazuko successfully\n"); if (dazukoVersion(&ver) != 0) { printf("error: failed to read Dazuko version\n"); dazukoUnregister(); return -1; } printf("Dazuko version %s (%d.%d.%d.%d)\n", ver.text, ver.major, ver.minor, ver.revision, ver.release); /* detect TERM signals */ signal(SIGTERM, sigterm); /* detect INT signals */ signal(SIGINT, sigterm); /* set access mask */ if (dazukoSetAccessMask(DAZUKO_ON_OPEN | DAZUKO_ON_CLOSE | DAZUKO_ON_CLOSE_MODIFIED | DAZUKO_ON_EXEC | DAZUKO_ON_UNLINK | DAZUKO_ON_RMDIR) != 0) { printf("error: failed to set access mask\n"); dazukoUnregister(); return -1; } printf("set access mask successfully\n"); /* set scan path */ for (i=1 ; i<argc ; i++) { if (argv[i][0] == '/') { if (dazukoAddIncludePath(argv[i]) != 0) { printf("error: failed to add %s include path\n", argv[i]); dazukoUnregister(); return -1; } args_ok = 1; } } /* ignore /dev/ */ if (dazukoAddExcludePath("/dev/") != 0) { printf("error: failed to add /dev/ exclude path\n"); dazukoUnregister(); return -1; } if (!args_ok) { print_usage(); dazukoUnregister(); return -1; } printf("set scan path successfully\n"); while (RUNNING) { /* get an access */ if (dazukoGetAccess(&acc) == 0) { print_access(acc); /* always allow access */ acc->deny = 0; /* return access (IMPORTANT, the kernel is waiting for us!) */ if (dazukoReturnAccess(&acc) != 0) { printf("error: failed to return access\n"); RUNNING = 0; } } else if (RUNNING) { printf("warning: failed to get an access\n"); RUNNING = 0; } } /* unregister with Dazuko */ if (dazukoUnregister() != 0) { printf("error: failed to unregister with Dazuko\n"); return -1; } printf("unregistered with Dazuko successfully\n"); return 0; }
void Class::printMethod() { const char * op_nameTable[256]={ //Primeira familia de instrucoes 0x0Xh "nop", "aconst_null", "iconst_m1", "iconst_0", "iconst_1", "iconst_2", "iconst3", "iconst_4", "iconst_5", "lconst_0", "lconst_1", "fconst_0", "fconst_1", "fconst_2", "dconst_0", "dconst_1", //Segunda familia de instrucoes 0x1Xh "bipush", "sipush", "ldc", "ldc_w", "ldc2_w", "iload", "lload", "fload", "dload", "aload", "iload_0", "iload_1", "iload_2", "iload_3", "lload_0", "lload_1", //Terceira familia de instrucoes 0x2Xh "lload_2", "lload_3", "fload_0", "fload_1", "fload_2", "fload_3", "dload_0", "dload_1", "dload_2", "dload_3", "aload_0", "aload_1", "aload_2", "aload_3", "iaload", "laload", //Quarta familia de instrucoes 0x3Xh "faload", "daload", "aaload", "baload", "caload", "saload", "istore", "lstore", "fstore", "dstore", "astore", "istore_0", "istore_1", "istore_2", "istore_3", "lstore_0", //Quinta familia de instrucoes 0x4Xh "lstore_1", "lstore_2", "lstore_3", "fstore_0", "fstore_1", "fstore_2", "fstore_3", "dstore_0", "dstore_1", "dstore_2", "dstore_3", "astore_0", "astore_1", "astore_2", "astore_3", "iastore", //Sexta familia de instrucoes 0x5Xh "lastore", "fastore", "dastore", "aastore", "bastore", "castore", "sastore", "pop", "pop2", "dup", "dup_x1", "dup_x2", "dup2", "dup2_x1", "dup2_x2", "swap", //Setima familia de instrucoes 0x6Xh "iadd", "ladd", "fadd", "dadd", "isub", "lsub", "fsub", "dsub", "imul", "lmul", "fmul", "dmul", "idiv", "ldiv", "fdiv", "ddiv", //Oitava familia de instrucoes 0x7Xh "irem", "lrem", "frem", "drem", "ineg", "lneg", "fneg", "dneg", "ishl", "lshl", "ishr", "lshr", "iushr", "lushr", "iand", "land", //Nona familia de instrucoes 0x8Xh "ior", "lor", "ixor", "lxor", "iinc", "i2l", "i2f", "i2d", "l2i", "l2f", "l2d", "f2i", "f2l", "f2d", "d2i", "d2l", //Decima familia de instrucoes 0x9Xh "d2f", "i2b", "i2c", "i2s", "lcmp", "fcmpl", "fcmpg", "dcmpl", "dcmpg", "ifeq", "ifne", "iflt", "ifge", "ifgt", "ifle", "if_icmpeq", //Decima primeira familia de instrucoes 0xAXh "if_icmpne", "if_icmplt", "if_icmpge", "if_icmpgt", "if_icmple", "if_acmpeg", "if_acmpne", "goto", "jsr", "ret", "table_switch", "lookup_switch", "ireturn", "lreturn", "freturn", "dreturn", //Decima segunda familia de instrucoes 0xBXh "areturn", "return", "getstatic", "putstatic", "getfield", "putfield", "invokevirtual", "invokespecial", "invokestatic", "invokeInterface", NULL, "new", "newArray", "anewArray", "arrayLength", "athrow", //Decima terceira familia de instrucoes 0xCXh "checkCast", "instanceOf", "monitorEnter", "monitorExit", "wide", "multiNewArray", "ifNull", "ifNonNull", "goto_w", "jsr_w", "breakPoint",NULL, NULL, NULL, NULL, NULL, //Decima quarta familia de instrucoes 0xDXh NULL, NULL, NULL, NULL,NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,NULL, NULL, NULL, NULL, //Decima quinta familia de instrucoes 0xEXh NULL, NULL, NULL, NULL,NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,NULL, NULL, NULL, NULL, //Decima sexta familia de instrucoes 0xFXh NULL, NULL, NULL, NULL,NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,NULL, NULL, "impdep1", "impdep2" }; for(int i=0;i<256; i++) { //printf("[%02X] %s\n",i,op_nameTable[i]); } for(int i=0;i<methods_count; i++) { printf("[%d] ", i); print_access(get_method_flags(i)); printf("%s: ", get_method_name(i)); printf("%s\n", get_method_descriptor(i)); Code *c = get_method_code(i); printf(" stack=%d, locals=%d\n", c->max_stack, c->max_locals); for(u2 pc = 0; pc<c->code_length; pc++) { u1 op = c->code[pc]; printf(" %2d: %s\t", pc, op_nameTable[op]); if( (op==0x10) || (op==0x15) || (op==0x16) || (op==0x17) || (op==0x18) || (op==0x19) || (op==0x36) || (op==0x37) || (op==0x38) || (op==0x39) || (op==0x3A) || (op==0xA9) || (op==0xBC) // 1 byte value ) { printf(" %d", (int8_t)c->code[++pc]); } else if( op==0x12 ) { // ldc u2 t = c->code[++pc]; printf(" #%d", t); print_cp_utf8(t); } else if( (op==0x13) || (op==0x14) || (op==0xB2) || (op==0xB3) || (op==0xB4) || (op==0xB5) || (op==0xB6) || (op==0xB7) || (op==0xB8) || (op==0xBB) || (op==0xBD) || (op==0xC0) || (op==0xC1) // constant pool index ) { u2 t = c->code[++pc]; t <<= 8; t |= c->code[++pc]; printf(" #%d", t); print_cp_utf8(t); } else if( (op==0x99) || (op==0x9A) || (op==0x9B) || (op==0x9C) || (op==0x9D) || (op==0x9E) || (op==0x9F) || (op==0xA0) || (op==0xA1) || (op==0xA2) || (op==0xA3) || (op==0xA4) || (op==0xA5) || (op==0xA6) || (op==0xA7) || (op==0xA8) || (op==0xC6) || (op==0xC7) // branch bytes ) { u2 t = c->code[++pc]; t <<= 8; t |= c->code[++pc]; t = (pc-2) + t; printf(" %d", t); } else if( op==0x11 ) { // sipush u2 t = c->code[++pc]; t <<= 8; t |= c->code[++pc]; printf(" %d", (int16_t)t); } else if( op==0x84 ) { // iinc printf(" %d,", c->code[++pc]); printf(" %d", c->code[++pc]); } else if( op==0xC5 ) { // multianewarray u2 t = c->code[++pc]; t <<= 8; t |= c->code[++pc]; printf(" #%d,", t); printf(" %d", c->code[++pc]); print_cp_utf8(t); } else if( op==0xB9 ) { // invokeinterface u2 t = c->code[++pc]; t <<= 8; t |= c->code[++pc]; printf(" #%d,", t); printf(" %d,", c->code[++pc]); printf(" %d", c->code[++pc]); print_cp_utf8(t); } else if( (op==0xC8) || (op==0xC9) ) { // goto_w, jsr_w u4 t = c->code[++pc]; t <<= 8; t |= c->code[++pc]; t <<= 8; t |= c->code[++pc]; t <<= 8; t |= c->code[++pc]; printf(" #%d", t); print_cp_utf8(t); } else if( op==0xC4 ) { // wide printf("\n"); op = c->code[++pc]; if(op!=0x84) { // <t>load, <t>store printf("%d: %s\t", pc, op_nameTable[op]); u2 t = c->code[++pc]; t <<= 8; t |= c->code[++pc]; printf(" #%d", t); print_cp_utf8(t); } else { // iinc printf("%d: %s\t", pc, op_nameTable[op]); u2 t = c->code[++pc]; t <<= 8; t |= c->code[++pc]; printf(" %d,", t); t = c->code[++pc]; t <<= 8; t |= c->code[++pc]; printf(" %d", t); } } printf("\n"); } printf("\n"); } }