-
-
Save SpringMT/3294204 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
use 5.017; | |
use utf8; | |
use B; | |
use Encode; | |
{ | |
sub MODIFY_CODE_ATTRIBUTES { | |
my ($pkg, $ref, @attrs) = @_; | |
my @bits; | |
for my $data (@attrs) { | |
$data =~ s/^ll_//; | |
$data =~ s/____/:/g; | |
$data =~ s/___/-/g; | |
$data =~ s/__/./g; | |
my @nums; | |
if (@nums = $data =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/) { | |
@nums = grep { /^[1-9][0-9]{0,2}$/ && $_ >= 0 && $_ < 256 } @nums; | |
push @bits, (@nums < 4 ? '11' : '01'); | |
} elsif (@nums = $data =~ /^([A-Z0-9]{1,4}):([A-Z0-9]{1,4}):([A-Z0-9]{1,4}):([A-Z0-9]{1,4}):([A-Z0-9]{1,4}):([A-Z0-9]{1,4}):([A-Z0-9]{1,4}):([A-Z0-9]{1,4})$/i) { | |
push @bits, ((grep { /^0/ } @nums) ? '11' : '10'); | |
} elsif ( | |
$data =~ /^[A-Z0-9]{2}:[A-Z0-9]{2}:[A-Z0-9]{2}:[A-Z0-9]{2}:[A-Z0-9]{2}:[A-Z0-9]{2}$/i || | |
$data =~ /^[A-Z0-9]{2}-[A-Z0-9]{2}-[A-Z0-9]{2}-[A-Z0-9]{2}-[A-Z0-9]{2}-[A-Z0-9]{2}$/i | |
) { | |
push @bits, '00'; | |
} else { | |
push @bits, '11'; | |
} | |
} | |
my $funcname = B::svref_2object($ref)->GV->NAME; | |
eval qq{ | |
no warnings 'redefine'; | |
*$pkg\::$funcname = sub { | |
say pack 'B*', join '', \@bits; | |
}; | |
}; | |
return; | |
} | |
} | |
my @attributes; | |
while (<>) { | |
chomp; | |
s/\./__/g; | |
s/-/___/g; | |
s/:/____/g; | |
s/[^_a-z-0-9]/_/gi; | |
push @attributes, "ll_$_"; | |
} | |
my $attribute = join " ", @attributes; | |
eval qq{ | |
sub ディケイド : $attribute {} | |
}; | |
say qq{ | |
sub ディケイド : $attribute {} | |
}; | |
ディケイド(); | |
__END__ | |
Perl の attribute という仕組みをつかって、問題となるデータ列をそれぞれ attribute として Perl のサブルーチンを宣言します。 | |
attribute に指定出来る文字列が決まってるので、良い感じに成形してからサブルーチンを宣言すると MODIFY_CODE_ATTRIBUTES が呼ばれるので、 MODIFY_CODE_ATTRIBUTES のなかで attribute を解析してデコードをして配列を作ります。 | |
配列を作成したあとに、定義されたサブルーチン名を MODIFY_CODE_ATTRIBUTES に渡されるコードリファレンスを元に取り出して、元のサブルーチンを再定義して、デコードの結果を表示するコードに差し替えるので、ユーザは最後に関数を呼びだすと attribute で指定された暗号の複合を簡単に出来るようになるわけです。 | |
かいつまむと、このスクリプトは | |
sub ディケイド : ll_232__193__40__138 ll_eaa9____ac9d____8214____7f05____c0c8____238____d1ea____488 ll_aebf____9b94____15f1____7f74____44fb____9603____bcc____5aaa ll_c4___64___16___b8___d8___9c ll_178__168__142__4 ll_f07d____a804____009f____8a61____2c32____b88c____ce01____a659 ll_46__229__220__208 ll_f0____29____5c____86____a3____4c ll_102__118__114__232 ll_ko9t0____D_dz_n ll_83__207__69__194 ll_24___b8___5a___bc___72___22 ll_136__22__201__116 ll__P_pB45YjXYPuf__HnY ll_84___f6___7f___37___b5___9c ll_9d___6a___c1___7f___98___3d ll_d3___dd___24___3f___97___9d ll_ou_kH_1c_HTh8_j_Ru ll_5e50____34f9____1324____5507____a8f8____cfd____bc96____280f ll_6901____45____cd15____2d75____c0da____b551____b248____a9bd ll_8c____3b____4c____b3____cc____02 ll_919a____b80c____c256____618b____1085____a850____92d7____b009 ll_S3ZFnviPdj___2__6 ll_nIo_mqY8aEL_AW04___43 ll_e9___fc___32___7e___6d___a4 ll_2245____6a9c____d67f____9c7f____fb99____b8a8____6af5____2657 ll___7u__D6Bb_ ll_y7rzH8KID____3p_____ ll_221__243__157__26 ll_1k_Z_rr0aHloiMIYj_3lQGGa_i ll_99___ce___91___f6___82___23 ll_219__171__250__241 ll_6__234__187__2 ll_034__254__205__219 ll_47__87__76__196 ll_238__213__64__125 ll_212__9__246__88 ll_ba59____88e____1e65____9171____88d8____9d76____37f7____79ce ll_a68f____8772____1a95____ce3d____3250____f207____ef1____9164 ll_237__133__201__76 ll_238__194__183__224 ll_229__130__053__191 ll_f853____9c38____f17b____45b8____bdc7____2cbc____9cad____b90f ll_afd8____a189____5b5f____3cd1____37c0____45f0____b215____b38a ll_b8___01___04___f9___3c___59 ll_b7b____c5bc____2d08____a9b3____9338____b89b____752b____437d ll_IgrqlsG00W9g_w_B_Ej6_ILV_41VnZ_z ll___nBL___D_XXZg ll_57__96__188__242 ll_5f3f____827b____6252____f775____4942____b16c____9a44____3ddc ll_23a0____4844____7827____0093____bb91____3e64____607c____cf1e ll_e1___4c___af___41___0a___e5 ll_197__166__29__58 ll_89f0____d2c3____95b5____517b____18a9____5166____26d2____6854 ll_439d____da0b____0bc9____a463____340c____d5be____5fc9____80cf ll_46____ad____3b____7d____17____49 ll_24__20__124__207 ll_c890____225b____65e9____f5b2____11fa____ad16____d2ae____a530 ll_157__196__12__81 ll_9a____ec____13____93____02____2a ll_131__217__155__208 ll_ab25____6060____39ba____e351____64a1____41c3____aaf0____e989 ll_53__191__111__157 ll_88__95__253__30 ll_243__239__33__209 ll_36b0____d9d8____5b5f____62bd____b722____1259____d1a6____8533 ll_c3___ab___92___51___cf___47 ll_b89e____6a02____c6ef____ea94____f37b____085c____5b01____ef8d ll_183__118__116__9 ll_409b____f34a____9d26____c358____f58a____c79c____23ca____9e06 ll_f0___f6___5e___97___4a___34 ll_9__175__157__180 ll_243__23__153__105 ll_624f____d278____de2d____bd60____9e3____b0b0____3866____4fe5 ll_36__107__60__140 ll_9f___bc___91___df___c7___b8 ll_39__87__217__3 ll_acd7____4f0d____bcad____bb2f____9fbb____9b4____63ab____e972 ll_240__59__200__250 ll_248__109__238__184 ll_07___9b___da___fb___f2___42 ll_8d49____ed08____e790____c930____cecd____78e2____8ad3____5946 ll_XwnMA_N_ElZTTtmO2_VtMlp ll_104__125__108__58 ll_223__183__93__10 ll_9e____35c7____4912____1f48____5b50____c221____b081____ba66 ll_fe____bc____43____a9____12____24 ll_008__016__065__149 ll_6__240__202__132 ll_41c3____1f2c____466e____8ab9____5177____3186____8____3230 ll_Na_DAvJeF1q_0G_04bL_c8_91__o ll_062__132__193__121 ll_215__157__221__197 ll_16ef____8cc0____9213____89ed____233f____1be0____db4c____2854 ll_GW_jZ_GPlR8N7SmB__Hsyx8_w3 ll_14bc____f200____72bd____4b97____8183____fbdb____55e7____d7a6 ll_83__33__91__156 ll_5998____99c____2689____93cd____aa9____4488____3eb7____3310 ll_41__92__65__218 ll_215__090__015__003 ll_140__6__201__210 ll_dGa_e8_w_p ll_06____6c____6b____48____59____20 ll_7a8a____2e16____d5fc____ab33____4bf2____aafc____88b8____a0f8 ll_234__6__94__203 ll_222e____6e04____d08b____c6c6____a5fc____c83f____2623____49725__39 ll_cb___67___57___8c___f4___93 ll_122__77__248__239 ll_v_82eNcy51rX_l_____de22____d003____4585 ll_0c23____d744____c5f2____302e____186e96d____be18____6e13____c470____2cf6____28e9 ll_c4____69____5__112 ll_127__130__75__139 ll_108__99__8__228 ll_fcb9____fab7____86d2____3e50____85b____583d____7... | |
というサブルーチンを宣言して、宣言したと同時に attribute にしていした暗号を bit 列にデコードしてから、 ディケイドというサブルーチンを再定義するので、ユーザは ディケイド というサブルーチンを呼び出すだけで複合化出来るのでお手軽ってことですね! | |
多分 perl 5.8 でも動かせるんで use 5.017 の行を消して decade ってファイル名に保存して、データファイルを onore ってファイル名で保存して | |
$ perl ./decate < ./onore | |
とかで実行すればいいんじゃないでしょうか | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
232.193.40.138 | |
eaa9:ac9d:8214:7f05:c0c8:238:d1ea:488 | |
aebf:9b94:15f1:7f74:44fb:9603:bcc:5aaa | |
c4-64-16-b8-d8-9c | |
178.168.142.4 | |
f07d:a804:009f:8a61:2c32:b88c:ce01:a659 | |
46.229.220.208 | |
f0:29:5c:86:a3:4c | |
102.118.114.232 | |
ko9t0:D;dz|n | |
83.207.69.194 | |
24-b8-5a-bc-72-22 | |
136.22.201.116 | |
=P`pB45YjXYPuf^;HnY | |
84-f6-7f-37-b5-9c | |
9d-6a-c1-7f-98-3d | |
d3-dd-24-3f-97-9d | |
ou_kH_1c^HTh8<j?Ru | |
5e50:34f9:1324:5507:a8f8:cfd:bc96:280f | |
6901:45:cd15:2d75:c0da:b551:b248:a9bd | |
8c:3b:4c:b3:cc:02 | |
919a:b80c:c256:618b:1085:a850:92d7:b009 | |
S3ZFnviPdj`^;2{]6 | |
nIo;mqY8aEL<AW04>?<43 | |
e9-fc-32-7e-6d-a4 | |
2245:6a9c:d67f:9c7f:fb99:b8a8:6af5:2657 | |
\_7u]@D6Bb< | |
y7rzH8KID:3p]: | |
221.243.157.26 | |
1k<Z\rr0aHloiMIYj=3lQGGa}i | |
99-ce-91-f6-82-23 | |
219.171.250.241 | |
6.234.187.2 | |
034.254.205.219 | |
47.87.76.196 | |
238.213.64.125 | |
212.9.246.88 | |
ba59:88e:1e65:9171:88d8:9d76:37f7:79ce | |
a68f:8772:1a95:ce3d:3250:f207:ef1:9164 | |
237.133.201.76 | |
238.194.183.224 | |
229.130.053.191 | |
f853:9c38:f17b:45b8:bdc7:2cbc:9cad:b90f | |
afd8:a189:5b5f:3cd1:37c0:45f0:b215:b38a | |
b8-01-04-f9-3c-59 | |
b7b:c5bc:2d08:a9b3:9338:b89b:752b:437d | |
IgrqlsG00W9g\w_B^Ej6[ILV_41VnZ}z | |
_;nBL<=^D;XXZg | |
57.96.188.242 | |
5f3f:827b:6252:f775:4942:b16c:9a44:3ddc | |
23a0:4844:7827:0093:bb91:3e64:607c:cf1e | |
e1-4c-af-41-0a-e5 | |
197.166.29.58 | |
89f0:d2c3:95b5:517b:18a9:5166:26d2:6854 | |
439d:da0b:0bc9:a463:340c:d5be:5fc9:80cf | |
46:ad:3b:7d:17:49 | |
24.20.124.207 | |
c890:225b:65e9:f5b2:11fa:ad16:d2ae:a530 | |
157.196.12.81 | |
9a:ec:13:93:02:2a | |
131.217.155.208 | |
ab25:6060:39ba:e351:64a1:41c3:aaf0:e989 | |
53.191.111.157 | |
88.95.253.30 | |
243.239.33.209 | |
36b0:d9d8:5b5f:62bd:b722:1259:d1a6:8533 | |
c3-ab-92-51-cf-47 | |
b89e:6a02:c6ef:ea94:f37b:085c:5b01:ef8d | |
183.118.116.9 | |
409b:f34a:9d26:c358:f58a:c79c:23ca:9e06 | |
f0-f6-5e-97-4a-34 | |
9.175.157.180 | |
243.23.153.105 | |
624f:d278:de2d:bd60:9e3:b0b0:3866:4fe5 | |
36.107.60.140 | |
9f-bc-91-df-c7-b8 | |
39.87.217.3 | |
acd7:4f0d:bcad:bb2f:9fbb:9b4:63ab:e972 | |
240.59.200.250 | |
248.109.238.184 | |
07-9b-da-fb-f2-42 | |
8d49:ed08:e790:c930:cecd:78e2:8ad3:5946 | |
XwnMA>N>ElZTTtmO2_VtMlp | |
104.125.108.58 | |
223.183.93.10 | |
9e:35c7:4912:1f48:5b50:c221:b081:ba66 | |
fe:bc:43:a9:12:24 | |
008.016.065.149 | |
6.240.202.132 | |
41c3:1f2c:466e:8ab9:5177:3186:8:3230 | |
Na\DAvJeF1q=0G=04bL}c8\91^>o | |
062.132.193.121 | |
215.157.221.197 | |
16ef:8cc0:9213:89ed:233f:1be0:db4c:2854 | |
GW]jZ@GPlR8N7SmB};Hsyx8[w3 | |
14bc:f200:72bd:4b97:8183:fbdb:55e7:d7a6 | |
83.33.91.156 | |
5998:99c:2689:93cd:aa9:4488:3eb7:3310 | |
41.92.65.218 | |
215.090.015.003 | |
140.6.201.210 | |
dGa;e8^w@p | |
06:6c:6b:48:59:20 | |
7a8a:2e16:d5fc:ab33:4bf2:aafc:88b8:a0f8 | |
234.6.94.203 | |
222e:6e04:d08b:c6c6:a5fc:c83f:2623:497 | |
a8:ee:cb:cd:1b:08 | |
203.33.48.195 | |
46.243.89.51 | |
a4ae:08e3:3c1f:e33c:c46b:cd7f:8f9f:681b | |
152.175.25.39 | |
cb-67-57-8c-f4-93 | |
122.77.248.239 | |
v;82eNcy51rX;l|@m|64D5 | |
3b-de-35-ab-1a-af | |
a655:07ab:3258:44f5:33ee:17b1:4d4e:1bcc | |
d0:b5:46:05:1c:aa | |
f7df:6c4b:1eab:1810:488f:de22:d003:4585 | |
0c23:d744:c5f2:302e:186e:9e57:ff88:bab8 | |
a21f:91b4:4912:eb6d:5250:1c08:5c9a:bf8a | |
124.87.156.161 | |
c0bf:6fe8:919f:e294:f80:5d0d:1a0d:afd3 | |
810a:5f52:396d:be18:6e13:c470:2cf6:28e9 | |
c4:69:a5:c6:e1:e2 | |
30.99.20.134 | |
SbA3 | |
154.71.106.46 | |
ab-1b-fb-2e-84-ec | |
231.7.238.127 | |
570:6a18:1a28:dfb1:8d34:54bf:1d0f:923e | |
123.196.025.112 | |
127.130.75.139 | |
108.99.8.228 | |
fcb9:fab7:86d2:3e50:855c:b4d2:e964:99 | |
d661:aa1e:0d94:c264:cb38:7579:b289:e041 | |
f8-96-8f-45-60-9b | |
b0-46-e9-16-06-b9 | |
59dd:19c9:e95b:583d:7719:d566:535e:472b | |
ed-af-07-20-db-89 | |
5a-00-b2-4f-6f-b8 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment