• R/O
  • SSH
  • HTTPS

naniya: Commit


Commit MetaInfo

Revision260 (tree)
Zeit2011-01-12 18:00:49
Autornotanpe

Log Message

特殊検索を実装。
gettid() をちょっとマシにした。

Ändern Zusammenfassung

Diff

--- branches/mty-makai/expr_scan.c (revision 259)
+++ branches/mty-makai/expr_scan.c (revision 260)
@@ -2228,7 +2228,7 @@
22282228 case 1:
22292229 YY_RULE_SETUP
22302230 #line 35 "expr_scan.lex"
2231-
2231+comment( yytext );
22322232 YY_BREAK
22332233 case 2:
22342234 YY_RULE_SETUP
--- branches/mty-makai/makai.h (nonexistent)
+++ branches/mty-makai/makai.h (revision 260)
@@ -0,0 +1,7 @@
1+#ifndef MAKAI_H__
2+#define MAKAI_H__
3+
4+#define MAKAI_TRUE 1
5+#define MAKAI_FALSE 0
6+
7+#endif /* MAKAI_H__ */
--- branches/mty-makai/expr_scan.lex (revision 259)
+++ branches/mty-makai/expr_scan.lex (revision 260)
@@ -32,7 +32,7 @@
3232 SJIS2 [\x40-\x7E\x80-\xFC]
3333 %%
3434
35-"#"[^\r\n]*[\r]*
35+"#"[^\r\n]*[\r]* comment( yytext );
3636
3737 ({CHAR}|{CHX}|{CHXE}){11,} expr_error("ターゲット<%s:%d文字くらい>は明らかに長すぎるので無視!", yytext, yyleng); return JUNK;
3838
--- branches/mty-makai/mty.c (revision 259)
+++ branches/mty-makai/mty.c (revision 260)
@@ -304,20 +304,15 @@
304304 優先度設定したりアイドルスレッド起こしても
305305 おもしろくないので、そのへんは今後の研究課題。 */
306306
307-#if 0
308307 #include <linux/unistd.h>
309-_syscall0(pid_t,gettid)
310-#define thread_get_tid() gettid()
311-#endif /* 0 */
308+#ifdef _syscall0
309+ _syscall0(pid_t,gettid)
310+ #define thread_get_tid() gettid()
311+#else /* _syscall0 */
312+ #include <sys/syscall.h>
313+ #define thread_get_tid() (pid_t)syscall(SYS_gettid)
314+#endif /* _syscall0 */
312315
313-#if 0
314-#include <sys/types.h>
315-#define thread_get_tid() gettid()
316-#endif /* 0 */
317-
318-#include <sys/syscall.h>
319-#define thread_get_tid() (pid_t)syscall(SYS_gettid)
320-
321316 static
322317 int thread_set_affinity(pid_t tid, int i)
323318 {
@@ -597,6 +592,8 @@
597592 int sCnt;
598593 int tmplCntMax;
599594 int maxSrchCnt;
595+ int verbose;
596+ DWORD priority;
600597
601598 /* 鍵文字列 */
602599 struct KS_KEY key;
@@ -632,8 +629,6 @@
632629 char *chPtr;
633630 uint64_t availMask;
634631 uint64_t pmask;
635- DWORD priority;
636- int verbose;
637632
638633 availMask = thread_avail(); /* 有効なマスク */
639634 availCPU = popcnt64( availMask ); /* 有効な CPU 数 */
@@ -752,7 +747,19 @@
752747
753748 nThread = popcnt64( proc_mask );
754749 printf( "%d 個の検索スレッドを起動\n", nThread );
750+}
755751
752+ assert((1 << N_STRIDE) == N_ALU * ALU_BITS);
753+
754+ mutex_key = CreateMutex(NULL, FALSE, NULL);
755+
756+#ifdef SPECIAL
757+ initSpecial();
758+#endif /* SPECIAL */
759+
760+ /* タゲ読み込み */
761+ root_expr = expr_parse("target.txt");
762+
756763 if ( verbose ) {
757764 int i;
758765 printf( "優先度を" );
@@ -777,9 +784,15 @@
777784 if ( fixedSalt[0] != '\0' ) {
778785 printf( "全空間モード (salt:%c%c)\n", fixedSalt[0], fixedSalt[1] );
779786 }
787+#ifdef SPECIAL
788+ dispSpecial();
789+#else /* SPECIAL */
790+ printf( "特殊検索は無効化されています\n" );
791+#endif /* SPECIAL */
780792 }
781793
782794 #ifdef WIN32
795+ /* 【注意】priority を上書きしている */
783796 switch ( priority ) {
784797 case PRIO_NORM : priority = NORMAL_PRIORITY_CLASS; break;
785798 case PRIO_BELO : priority = BELOW_NORMAL_PRIORITY_CLASS; break;
@@ -787,15 +800,7 @@
787800 }
788801 SetPriorityClass( GetCurrentProcess(), priority );
789802 #endif
790-}
791803
792- assert((1 << N_STRIDE) == N_ALU * ALU_BITS);
793-
794- mutex_key = CreateMutex(NULL, FALSE, NULL);
795-
796- /* タゲ読み込み */
797- root_expr = expr_parse("target.txt");
798-
799804 /* コードを生成・展開
800805 起動予定スレッド数に応じて
801806 生成するコードを変える */
--- branches/mty-makai/special.c (nonexistent)
+++ branches/mty-makai/special.c (revision 260)
@@ -0,0 +1,244 @@
1+#include <stdio.h>
2+#include <stdlib.h>
3+#include <string.h>
4+
5+#include "special.h"
6+#include "util.h"
7+
8+#define TRIP_LEN 10
9+
10+#define ST_ALLN 1 /* 全数 */
11+#define ST_NIKO 1<<0x1 /* 二構 */
12+#define ST_BUOO 1<<0x8 /* ぶお */
13+#define ST_DOSU 1<<0x9 /* 怒数 */
14+#define ST_CHIN 1<<0xb /* ちん */
15+#define ST_EROI 1<<0xc /* エロ */
16+#define ST_HREN 1<<0xd /* 飛連 */
17+#define ST_YAKU 1<<0xe /* 八雲 */
18+
19+int special;
20+
21+static FILE *nfp; /* 全数 */
22+#define LOGNUM "lognum.txt"
23+static FILE *cfp; /* ち */
24+#define LOGCHI "logchi.txt"
25+static FILE *tfp; /* ↑以外の特殊検索 */
26+#define LOGSPE "logspe.txt"
27+
28+void
29+dispSpecial()
30+{
31+ printf( "特殊検索オプション : " );
32+ if ( special & ST_DOSU ) {
33+ printf( "怒数 " );
34+ } else {
35+ if ( special & ST_ALLN ) {
36+ printf( "全数 " );
37+ }
38+ }
39+ if ( special & ST_EROI ) {
40+ printf( "エロ " );
41+ }
42+ if ( special & ST_NIKO ) {
43+ printf( "二構 " );
44+ }
45+ if ( special & ST_BUOO ) {
46+ printf( "ぶお " );
47+ }
48+ if ( special & ST_CHIN ) {
49+ printf( "ちん " );
50+ }
51+ if ( special & ST_HREN ) {
52+ printf( "飛連 " );
53+ }
54+ if ( special & ST_YAKU ) {
55+ printf( "八雲 " );
56+ }
57+ if ( special ) {
58+ printf( "オン!\n" );
59+ } else {
60+ printf( "オールオフ!\n" );
61+ }
62+}
63+
64+void
65+initSpecial()
66+{
67+ special = 0;
68+
69+ if ( (tfp = fopen( LOGSPE, "at" )) == NULL ) {
70+ perror( LOGSPE );
71+ exit( 1 );
72+ }
73+ setvbuf( tfp, NULL, _IONBF, BUFSIZ );
74+
75+ if ( (nfp = fopen( LOGNUM, "at" )) == NULL ) {
76+ perror( LOGNUM );
77+ exit( 1 );
78+ }
79+ setvbuf( nfp, NULL, _IONBF, BUFSIZ );
80+
81+ if ( (cfp = fopen( LOGCHI, "at" )) == NULL ) {
82+ perror( LOGCHI );
83+ exit( 1 );
84+ }
85+ setvbuf( cfp, NULL, _IONBF, BUFSIZ );
86+}
87+
88+void
89+comment( str )
90+char *str;
91+{
92+ if ( strlen( str ) >= 4 ) {
93+ if ( str[1] == '[' && str[3] == ']' ) {
94+ switch ( str[2] ) {
95+ case '0': special |= ST_ALLN; break;
96+ case '1': special |= ST_NIKO; break;
97+ case '8': special |= ST_BUOO; break;
98+ case '9': special |= (ST_DOSU | ST_ALLN); break;
99+ case 'd': special |= ST_HREN; break;
100+ case 'e': special |= ST_YAKU; break;
101+ case 'Y': special |= ST_CHIN; break;
102+ case 'Z': special |= ST_EROI; break;
103+#if 0
104+#ifdef KEYLOG
105+ case 'K': keyLog = MAKAI_TRUE; break;
106+#endif /* KEYLOG */
107+ case 'S':
108+ seedOffset = atoi( str + 4 );
109+ if ( seedOffset < MIN_SOFF || seedOffset > MAX_SOFF ) {
110+ fprintf( stderr, "乱数の種のオフセットは、%d 以上 %d 以下で指定してね。\n", MIN_SOFF, MAX_SOFF );
111+ fprintf( stderr, "%d は範囲外なので無視します。\n", seedOffset );
112+ seedOffset = 0;
113+ }
114+ break;
115+#endif /* 0 */
116+ }
117+ }
118+ }
119+}
120+
121+/* ヒット時には出力ファイルへのポインタを返す */
122+FILE *
123+checkSpecial( trip, kind )
124+char *trip;
125+unsigned char *kind;
126+{
127+ OLDPRINT( "trip %s\n", trip );
128+
129+ if ( special & ST_CHIN ) {
130+ /* ^Chi(r */
131+ if ( trip[0] == 'C' && trip[1] == 'h' && trip[2] == 'i' &&
132+ trip[3] == 'n' && trip[4] == 'k' && trip[5] == 'o' ) {
133+ strcpy( kind, "ち" );
134+ return( cfp );
135+ }
136+ }
137+
138+ if ( special & ST_BUOO ) {
139+ /* ぶお [A-Za-z]aoo[A-Za-z]uoo$ */
140+ if ( trip[3] == 'a' && trip[4] == 'o' && trip[5] == 'o' &&
141+ trip[7] == 'u' && trip[8] == 'o' && trip[9] == 'o' &&
142+ isalpha( trip[2] ) && isalpha( trip[6] ) ) {
143+ strcpy( kind, "ぶ" );
144+ return( tfp );
145+ }
146+ }
147+
148+ if ( special & ST_EROI ) {
149+ int i;
150+ /* エロい人型二構 その 1 looooloooo */
151+ if ( trip[0] == trip[5] &&
152+ trip[1] == trip[2] && trip[1] == trip[3] && trip[1] == trip[4] &&
153+ trip[1] == trip[6] && trip[1] == trip[7] && trip[1] == trip[8] &&
154+ trip[1] == trip[9] ) {
155+ strcpy( kind, "エ" );
156+ return( tfp );
157+ }
158+ /* エロい人型二構 その 2 [./] */
159+ for ( i = 0; i < TRIP_LEN; i++ ) {
160+ if ( trip[i] != '.' && trip[i] != '/' ) {
161+ goto NOEROI;
162+ }
163+ }
164+ strcpy( kind, "エ" );
165+ return( tfp );
166+ }
167+ NOEROI:
168+
169+ if ( special & ST_NIKO ) {
170+ /* 二構 */
171+ int i;
172+ char ch1, ch2;
173+ ch1 = trip[0];
174+ for ( i = 1; i < TRIP_LEN; i++ ) {
175+ if ( trip[i] != ch1 ) break;
176+ }
177+ ch2 = trip[i];
178+ for ( ; i < TRIP_LEN; i++ ) {
179+ if ( trip[i] != ch1 && trip[i] != ch2 ) goto NONIKO;
180+ }
181+ strcpy( kind, "二" );
182+ return( tfp );
183+ }
184+ NONIKO:
185+
186+ if ( special & ST_YAKU ) {
187+ /* 八雲 */
188+ if ( trip[0] == trip[1] && trip[0] == trip[2] &&
189+ trip[3] == trip[4] && trip[3] == trip[5] &&
190+ trip[6] == trip[7] && trip[6] == trip[8] && trip[9] == '.' ) {
191+ strcpy( kind, "八" );
192+ return( tfp );
193+ }
194+ }
195+
196+ /* 飛連関連のコードは、セロリン ◆Celeron/rc 作 */
197+ if ( special & ST_HREN ) {
198+ /* 飛連 */
199+ int w, x = 0, y = 0;
200+ for ( w = 0; w < TRIP_LEN; w++ ) {
201+ if ( trip[w] == trip[0] ) x += 1;
202+ if ( trip[w] == trip[1] ) y += 1;
203+ if ( x >= 8 || y >= 8 ) {
204+ strcpy( kind, "飛" );
205+ return( tfp );
206+ }
207+ }
208+ }
209+
210+ if ( special & ST_ALLN ) {
211+ /* 全数 か 怒数 */
212+ if ( isdigit( trip[0] ) && isdigit( trip[1] ) && isdigit( trip[2] ) &&
213+ isdigit( trip[3] ) && isdigit( trip[4] ) && isdigit( trip[5] ) &&
214+ isdigit( trip[6] ) && isdigit( trip[7] ) && isdigit( trip[8] ) &&
215+ isdigit( trip[9] ) ) {
216+ if ( special & ST_DOSU ) {
217+ /* 全数 & 回文 */
218+ if ( trip[0] == trip[9] && trip[1] == trip[8] && trip[2] == trip[7] &&
219+ trip[3] == trip[6] && trip[4] == trip[5] ) {
220+ strcpy( kind, "怒" );
221+ return( tfp );
222+ }
223+ /* 全数 & 双連 */
224+ if ( trip[0] == trip[1] && trip[2] == trip[3] && trip[4] == trip[5] &&
225+ trip[6] == trip[7] && trip[8] == trip[9] ) {
226+ strcpy( kind, "怒" );
227+ return( tfp );
228+ }
229+ /* 全数 & 山彦 */
230+ if ( trip[0] == trip[5] && trip[1] == trip[6] && trip[2] == trip[7] &&
231+ trip[3] == trip[8] && trip[4] == trip[9] ) {
232+ strcpy( kind, "怒" );
233+ return( tfp );
234+ }
235+ /* 最大と最小は、純 8 連で出るので削除 */
236+ } else {
237+ strcpy( kind, "数" );
238+ return( nfp );
239+ }
240+ }
241+ }
242+
243+ return( NULL );
244+}
--- branches/mty-makai/log.c (revision 259)
+++ branches/mty-makai/log.c (revision 260)
@@ -47,13 +47,16 @@
4747
4848 static
4949 int
50-log_printf(char const *fmt, ...)
50+log_printf(FILE *fp, char const *fmt, ...)
5151 {
5252 int r;
5353 va_list ap;
5454 va_start(ap, fmt);
5555 vfprintf(stdout, fmt, ap);
56- r = vfprintf(ofp, fmt, ap);
56+ if ( fp == NULL ) {
57+ fp = ofp;
58+ }
59+ r = vfprintf(fp, fmt, ap);
5760 va_end(ap);
5861 if (r > 0)
5962 return r;
@@ -62,7 +65,7 @@
6265 }
6366
6467 void
65-log_print(int full, char const *hash, uint8_t const *key)
68+log_print(FILE *fp, int full, char const *hash, uint8_t const *key)
6669 {
6770 struct timeb tb;
6871 struct tm *plt;
@@ -76,7 +79,7 @@
7679
7780 if (full && fixedSalt[0] == '\0')
7881 {
79- log_printf("◆%s #%s"
82+ log_printf(fp, "◆%s #%s"
8083 "\t%04d/%02d/%02d %02d:%02d:%02d.%03d"
8184 "\t(%02X %02X %02X %02X %02X %02X %02X %02X/%02X)\n",
8285 hash,
@@ -94,7 +97,7 @@
9497 }
9598 else
9699 {
97- log_printf("◆%s ##%02x%02x%02x%02x%02x%02x%02x%02x%s"
100+ log_printf(fp, "◆%s ##%02x%02x%02x%02x%02x%02x%02x%02x%s"
98101 "\t%04d/%02d/%02d %02d:%02d:%02d.%03d"
99102 "\t \n", /* ……。ま、いっか */
100103 hash,
--- branches/mty-makai/hit.c (revision 259)
+++ branches/mty-makai/hit.c (revision 260)
@@ -6,6 +6,7 @@
66 *
77 */
88
9+#include <stdio.h>
910 #include <string.h>
1011
1112 #include "desconst.h"
@@ -83,6 +84,10 @@
8384 int xkey_loaded = 0;
8485 uint8_t xkey_buf[8][16][8];
8586
87+#ifdef SPECIAL
88+ extern int special;
89+#endif /* SPECIAL */
90+
8691 for (kk = 0; kk < N_ALU; kk++)
8792 {
8893
@@ -90,6 +95,35 @@
9095 if (!(kk & (N_ALU / N_Q - 1)))
9196 xhash_loaded = 0;
9297
98+#ifdef SPECIAL
99+ if ( special ) {
100+ char hash[16];
101+ FILE *lfp;
102+ unsigned char kind[3];
103+ uint8_t buf[32];
104+
105+ CALL_TR64(&pkt_c->param64.lr[0][0].q[kk / (N_ALU / N_Q)], xhash);
106+ xhash_loaded = 1;
107+ for ( k = 0; k < ALU_BITS; k++ ) {
108+ for ( i = 1; i < 11; i++ ) {
109+ unsigned c = 0;
110+ c = (xhash[(ALU_BITS * kk + k) & 63] >> (6 * (i - 1))) & 0x3F;
111+ hash[i - 1] = C64[c];
112+ }
113+ hash[10] = 0;
114+ if ( (lfp = checkSpecial( hash, kind )) != NULL ) {
115+ trk8(pkt_c, &xkey_buf[0][0][0]);
116+ xkey_loaded = 1;
117+ for ( i = 0; i < 8; i++ ) {
118+ buf[i] = xkey_buf[i][0][((ALU_BITS * kk + k) >> 3) | (((ALU_BITS * kk + k) & 7) << 4)];
119+ }
120+ buf[8] = buf[9] = 0;
121+ log_print(lfp, translate(buf, 0, 1), hash, buf);
122+ }
123+ }
124+ }
125+#endif /* SPECIAL */
126+
93127 t = hit[HIT_ANY].a[kk];
94128 if (!t)
95129 continue;
@@ -138,7 +172,7 @@
138172 }
139173 else
140174 {
141- log_print(translate(buf, 0, 1), hash, buf);
175+ log_print(NULL, translate(buf, 0, 1), hash, buf);
142176 }
143177 }
144178 }
--- branches/mty-makai/special.h (nonexistent)
+++ branches/mty-makai/special.h (revision 260)
@@ -0,0 +1,9 @@
1+#ifndef SPECIAL_H__
2+#define SPECIAL_H__
3+
4+void comment( char *str );
5+FILE *checkSpecial( char *trip, unsigned char *kind );
6+void initSpecial();
7+void dispSpecial();
8+
9+#endif /* SPECIAL_H__ */
--- branches/mty-makai/log.h (revision 259)
+++ branches/mty-makai/log.h (revision 260)
@@ -4,6 +4,6 @@
44 #include "mtytypes.h"
55
66 extern int log_open(char const *name);
7-extern void log_print(int full, char const *hash, uint8_t const *key);
7+extern void log_print(FILE *fp, int full, char const *hash, uint8_t const *key);
88
99 #endif /* LOG_H__ */
Show on old repository browser