-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
1448 lines (845 loc) · 181 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge" >
<link rel="dns-prefetch" href="http://yoursite.com">
<title>南楼</title>
<meta name="generator" content="hexo-theme-yilia-plus">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<!-- <meta name="keywords" content="">
<meta name="description" content=""> -->
<meta property="og:type" content="website">
<meta property="og:title" content="南楼">
<meta property="og:url" content="http://yoursite.com/index.html">
<meta property="og:site_name" content="南楼">
<meta property="og:locale" content="default">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="南楼">
<link rel="icon" href="/favicon.ico">
<link rel="apple-touch-icon" href="/apple-touch-icon-180x180.png">
<link rel="stylesheet" type="text/css" href="/./main.a5fda8.css">
<style type="text/css">
#container.show {
background: linear-gradient(200deg,#a0cfe4,#e8c37e);
}
</style>
<script src="/lib/clickLove.js"></script>
<script src="/lib/pace.min.js"></script>
<link href="//cdn.bootcss.com/pace/1.0.2/themes/blue/pace-theme-minimal.css" rel="stylesheet">
</head>
<body>
<div id="container" q-class="show:isCtnShow">
<canvas id="anm-canvas" class="anm-canvas"></canvas>
<div class="left-col" q-class="show:isShow">
<div class="overlay" style="background: #4d4d4d;"></div>
<div class="intrude-less">
<header id="header" class="inner">
<a href="/" class="profilepic">
<img src="/img/avatar.jpg" class="js-avatar">
</a>
<hgroup>
<h1 class="header-author"><a href="/">南楼清月</a></h1>
</hgroup>
<nav class="header-menu">
<ul>
<li><a href="/" >主页</a></li>
</ul>
</nav>
<nav class="header-smart-menu">
<a q-on="click: openSlider(e, 'innerArchive')" href="javascript:void(0)">所有文章</a>
<a q-on="click: openSlider(e, 'aboutme')" href="javascript:void(0)">关于我</a>
</nav>
<nav class="header-nav">
<div class="social">
<a class="github" href="https://github.com/nan-lou" title="GitHub" ><i class="icon-github"></i></a>
</div>
<div>
<iframe frameborder="no" border="0" marginwidth="0" marginheight="0" width="240" height="86" src="//music.163.com/outchain/player?type=2&id=29047169&auto=0&height=66"></iframe>
</div>
<p style="font-size: 12px;">这似乎是首纯音乐,请尽情的欣赏它吧!<p>
</nav>
</header>
</div>
</div>
<div class="mid-col" q-class="show:isShow,hide:isShow|isFalse">
<nav id="mobile-nav">
<div class="overlay js-overlay" style="background: #4d4d4d"></div>
<div class="btnctn js-mobile-btnctn">
<div class="slider-trigger list" q-on="click: openSlider(e)"><i class="icon icon-sort"></i></div>
</div>
<div class="intrude-less">
<header id="header" class="inner">
<div class="profilepic">
<a href="/">
<img src="/img/avatar.jpg" class="js-avatar">
</a>
</div>
<hgroup>
<h1 class="header-author js-header-author">南楼清月</h1>
</hgroup>
<nav class="header-nav">
<div class="social">
<a class="github" target="_blank" href="https://github.com/nan-lou" title="GitHub"><i class="icon-github"></i></a>
</div>
</nav>
<nav class="header-menu js-header-menu">
<ul style="width: 50%">
<li style="width: 100%"><a href="/">主页</a></li>
</ul>
</nav>
</header>
</div>
<div class="mobile-mask" style="display:none" q-show="isShow"></div>
</nav>
<div id="wrapper" class="body-wrap">
<div class="menu-l">
<div class="canvas-wrap">
<canvas data-colors="#eaeaea" data-sectionHeight="100" data-contentId="js-content" id="myCanvas1"
class="anm-canvas"></canvas>
</div>
<div id="js-content" class="content-ll">
<article id="post-在Java11下调用jdk-internal-misc-Unsafe的方式" class="article article-type-post article-index" itemscope itemprop="blogPost">
<div class="article-inner">
<header class="article-header">
<h1 itemprop="name">
<a class="article-title" href="/2020/07/04/在Java11下调用jdk-internal-misc-Unsafe的方式/">在Java11下调用jdk.internal.misc.Unsafe的方式</a>
</h1>
<a href="/2020/07/04/在Java11下调用jdk-internal-misc-Unsafe的方式/" class="archive-article-date">
<time datetime="2020-07-03T16:45:40.000Z" itemprop="datePublished"><i class="icon-calendar icon"></i>2020-07-04</time>
</a>
</header>
<div class="article-entry" itemprop="articleBody">
<h2 id="Java11的模块化"><a href="#Java11的模块化" class="headerlink" title="Java11的模块化"></a>Java11的模块化</h2><p>Java9引入了的模块化相关的内容,将JDK的jar总共分为了module,将之前的Class和Class之间的依赖简化为module和module之间的依赖。每个模块由一个叫module-info.java的文件说明引入和导出相关的API。<strong>未导出的API无法在其他模块内被使用</strong>。</p>
<p>只有手动在module-info.java内声明,才可以被调用,并且只能声明那些已经导出的模块 。而jdk为了安全考虑,并<strong>没有导出jdk.internal.misc.Unsafe</strong>。</p>
<h2 id="Unsafe类"><a href="#Unsafe类" class="headerlink" title="Unsafe类"></a>Unsafe类</h2><pre><code>Jdk中的Unsafe类有两个分别是 sun.misc.Unsafe和 jdk.internal.misc.Unsafe。
</code></pre><p> <strong>sun.misc.Unsafe</strong>:该类是对 jdk.internal.misc.Unsafe再封装,开放了一些不那么’unsafe’的API。</p>
<p> <strong>jdk.internal.misc.Unsafe</strong>,该类并未导出,甚至无法import。</p>
<p> sun.misc.Unsafe实例可以通过反射拿到其单例对象,可以直接进行方法调用。<br> 但是jdk.internal.misc.Unsafe拿到实例后也无法正常用。因为无法import;想要调用只能通过反射,但是反射调用又需要进行权限检查,这看起来似乎无解。但是jdk依旧给我们留了一个口子: <strong>sun.misc.Unsafe类进行属性设置的时候是无视权限检查的</strong>;这时候我们可以分析反射调用时权限检查相关的代码,进行绕过。</p>
<a class="article-more-a" href="/2020/07/04/在Java11下调用jdk-internal-misc-Unsafe的方式/#more">more >></a>
</div>
<div class="article-info article-info-index">
<div class="article-tag tagcloud">
<i class="icon-price-tags icon"></i>
<ul class="article-tag-list">
<li class="article-tag-list-item">
<a href="javascript:void(0)" class="js-tag article-tag-list-link color5">Java</a>
</li>
</ul>
</div>
<p class="article-more-link">
<a class="article-more-a" href="/2020/07/04/在Java11下调用jdk-internal-misc-Unsafe的方式/">展开全文 >></a>
</p>
<div class="clearfix"></div>
</div>
</div>
</article>
<aside class="wrap-side-operation">
<div class="mod-side-operation">
<div class="jump-container" id="js-jump-container" style="display:none;">
<a href="javascript:void(0)" class="mod-side-operation__jump-to-top">
<i class="icon-font icon-back"></i>
</a>
<div id="js-jump-plan-container" class="jump-plan-container" style="top: -11px;">
<i class="icon-font icon-plane jump-plane"></i>
</div>
</div>
</div>
</aside>
<article id="post-关于策略模式一些思考" class="article article-type-post article-index" itemscope itemprop="blogPost">
<div class="article-inner">
<header class="article-header">
<h1 itemprop="name">
<a class="article-title" href="/2020/06/30/关于策略模式一些思考/">关于策略模式一些思考</a>
</h1>
<a href="/2020/06/30/关于策略模式一些思考/" class="archive-article-date">
<time datetime="2020-06-30T13:13:47.000Z" itemprop="datePublished"><i class="icon-calendar icon"></i>2020-06-30</time>
</a>
</header>
<div class="article-entry" itemprop="articleBody">
<p>本篇文章来源于和球哥吹牛逼的总结。</p>
<h2 id="原因"><a href="#原因" class="headerlink" title="原因"></a>原因</h2><p>前两天我在开开心心地当个死宅,球哥突然甩给我一个链接,说这篇文章的策略模式实现是不是有问题。</p>
<p>链接里面的策略模式是这么写的:</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 以下只有核心代码</span></span><br><span class="line"><span class="comment"> * ChargeEnum为策略类型</span></span><br><span class="line"><span class="comment"> * ChargeStrategy策略接口</span></span><br><span class="line"><span class="comment"> * StrategyFactory策略工厂</span></span><br><span class="line"><span class="comment"> * Context运行时上下文</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">enum</span> ChargeEnum {</span><br><span class="line"> CARD, ACCOUNT, PHONE</span><br><span class="line">}</span><br><span class="line"><span class="class"><span class="keyword">interface</span> <span class="title">ChargeStrategy</span> </span>{</span><br><span class="line"> <span class="function"><span class="keyword">double</span> <span class="title">charge</span><span class="params">(<span class="keyword">double</span> num, ChargeEnum e)</span></span>;</span><br><span class="line">}</span><br></pre></td></tr></table></figure>
<a class="article-more-a" href="/2020/06/30/关于策略模式一些思考/#more">more >></a>
</div>
<div class="article-info article-info-index">
<div class="article-tag tagcloud">
<i class="icon-price-tags icon"></i>
<ul class="article-tag-list">
<li class="article-tag-list-item">
<a href="javascript:void(0)" class="js-tag article-tag-list-link color5">Java</a>
</li>
<li class="article-tag-list-item">
<a href="javascript:void(0)" class="js-tag article-tag-list-link color5">设计模式</a>
</li>
</ul>
</div>
<p class="article-more-link">
<a class="article-more-a" href="/2020/06/30/关于策略模式一些思考/">展开全文 >></a>
</p>
<div class="clearfix"></div>
</div>
</div>
</article>
<aside class="wrap-side-operation">
<div class="mod-side-operation">
<div class="jump-container" id="js-jump-container" style="display:none;">
<a href="javascript:void(0)" class="mod-side-operation__jump-to-top">
<i class="icon-font icon-back"></i>
</a>
<div id="js-jump-plan-container" class="jump-plan-container" style="top: -11px;">
<i class="icon-font icon-plane jump-plane"></i>
</div>
</div>
</div>
</aside>
<article id="post-Callable实现原理浅析" class="article article-type-post article-index" itemscope itemprop="blogPost">
<div class="article-inner">
<header class="article-header">
<h1 itemprop="name">
<a class="article-title" href="/2020/06/26/Callable实现原理浅析/">Callable实现原理浅析</a>
</h1>
<a href="/2020/06/26/Callable实现原理浅析/" class="archive-article-date">
<time datetime="2020-06-25T16:13:02.000Z" itemprop="datePublished"><i class="icon-calendar icon"></i>2020-06-26</time>
</a>
</header>
<div class="article-entry" itemprop="articleBody">
<h2 id="一、实现线程的方式"><a href="#一、实现线程的方式" class="headerlink" title="一、实现线程的方式"></a>一、实现线程的方式</h2><p>JSR133中规定到:</p>
<blockquote>
<p>Threads are represented by the <code>Thread</code> class. The only way for a user to create a thread is to create an object of this class; each thread is associated with such an object. A thread will start when the <code>start()</code> method is invoked on the corresponding <code>Thread</code> object.</p>
</blockquote>
<p>翻译过来就是:</p>
<blockquote>
<p>线程是用 Thread 类来表示的。用户创建一个线程 的唯一方式是创建一个该类的对象;每个线程都与这样一个对象相关联。在对应的 Thread 对象上调用 start()方法将启动线程。</p>
</blockquote>
<p>所以说,<strong>创建线程的唯一方式只有new Thread()</strong>,线程在调用<strong>Thread#start()</strong>方法后启动。</p>
<a class="article-more-a" href="/2020/06/26/Callable实现原理浅析/#more">more >></a>
</div>
<div class="article-info article-info-index">
<div class="article-tag tagcloud">
<i class="icon-price-tags icon"></i>
<ul class="article-tag-list">
<li class="article-tag-list-item">
<a href="javascript:void(0)" class="js-tag article-tag-list-link color5">Java</a>
</li>
<li class="article-tag-list-item">
<a href="javascript:void(0)" class="js-tag article-tag-list-link color4">多线程</a>
</li>
</ul>
</div>
<p class="article-more-link">
<a class="article-more-a" href="/2020/06/26/Callable实现原理浅析/">展开全文 >></a>
</p>
<div class="clearfix"></div>
</div>
</div>
</article>
<aside class="wrap-side-operation">
<div class="mod-side-operation">
<div class="jump-container" id="js-jump-container" style="display:none;">
<a href="javascript:void(0)" class="mod-side-operation__jump-to-top">
<i class="icon-font icon-back"></i>
</a>
<div id="js-jump-plan-container" class="jump-plan-container" style="top: -11px;">
<i class="icon-font icon-plane jump-plane"></i>
</div>
</div>
</div>
</aside>
<article id="post-搭建自己的git服务器" class="article article-type-post article-index" itemscope itemprop="blogPost">
<div class="article-inner">
<header class="article-header">
<h1 itemprop="name">
<a class="article-title" href="/2020/06/23/搭建自己的git服务器/">搭建自己的git服务器</a>
</h1>
<a href="/2020/06/23/搭建自己的git服务器/" class="archive-article-date">
<time datetime="2020-06-23T15:27:30.000Z" itemprop="datePublished"><i class="icon-calendar icon"></i>2020-06-23</time>
</a>
</header>
<div class="article-entry" itemprop="articleBody">
<h2 id="写在前面"><a href="#写在前面" class="headerlink" title="写在前面"></a>写在前面</h2><p>打算重新开始写博客,直接用现成的Hexo。Hexo教程一般使用Github作为默认的服务器,但是我想推送到自己的服务器上,所以打算自己搭建一个博客仓库。</p>
<h2 id="具体步骤"><a href="#具体步骤" class="headerlink" title="具体步骤"></a>具体步骤</h2><p>Linux, Linux需要安装git, 本地安装git</p>
<h2 id="采用RSA认证"><a href="#采用RSA认证" class="headerlink" title="采用RSA认证"></a>采用RSA认证</h2><p>常见的RSA git 链接一般都是:</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">[email protected]:xxx.git</span><br></pre></td></tr></table></figure>
<a class="article-more-a" href="/2020/06/23/搭建自己的git服务器/#more">more >></a>
</div>
<div class="article-info article-info-index">
<div class="article-tag tagcloud">
<i class="icon-price-tags icon"></i>
<ul class="article-tag-list">
<li class="article-tag-list-item">
<a href="javascript:void(0)" class="js-tag article-tag-list-link color1">Linux</a>
</li>
<li class="article-tag-list-item">
<a href="javascript:void(0)" class="js-tag article-tag-list-link color4">git</a>
</li>
</ul>
</div>
<p class="article-more-link">
<a class="article-more-a" href="/2020/06/23/搭建自己的git服务器/">展开全文 >></a>
</p>
<div class="clearfix"></div>
</div>
</div>
</article>
<aside class="wrap-side-operation">
<div class="mod-side-operation">
<div class="jump-container" id="js-jump-container" style="display:none;">
<a href="javascript:void(0)" class="mod-side-operation__jump-to-top">
<i class="icon-font icon-back"></i>
</a>
<div id="js-jump-plan-container" class="jump-plan-container" style="top: -11px;">
<i class="icon-font icon-plane jump-plane"></i>
</div>
</div>
</div>
</aside>
<article id="post-基本类型的++操作原理" class="article article-type-post article-index" itemscope itemprop="blogPost">
<div class="article-inner">
<header class="article-header">
<h1 itemprop="name">
<a class="article-title" href="/2019/08/30/基本类型的++操作原理/">基本类型的++操作原理</a>
</h1>
<a href="/2019/08/30/基本类型的++操作原理/" class="archive-article-date">
<time datetime="2019-08-30T02:54:31.000Z" itemprop="datePublished"><i class="icon-calendar icon"></i>2019-08-30</time>
</a>
</header>
<div class="article-entry" itemprop="articleBody">
<p>对于所有基本类型的++操作源代码如下:</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">int</span> <span class="title">test</span><span class="params">()</span></span>{</span><br><span class="line"> <span class="keyword">byte</span> a = <span class="number">1</span>;</span><br><span class="line"> a++;</span><br><span class="line"> <span class="keyword">char</span> b = <span class="number">1</span>;</span><br><span class="line"> b++;</span><br><span class="line"> <span class="keyword">short</span> c = <span class="number">1</span>;</span><br><span class="line"> c++;</span><br><span class="line"> <span class="keyword">int</span> d = <span class="number">1</span>;</span><br><span class="line"> d++;</span><br><span class="line"> <span class="keyword">long</span> e = <span class="number">1</span>;</span><br><span class="line"> e++;</span><br><span class="line"> <span class="keyword">float</span> f = <span class="number">1</span>;</span><br><span class="line"> f++;</span><br><span class="line"> <span class="keyword">double</span> g = <span class="number">1</span>;</span><br><span class="line"> g++;</span><br><span class="line"> <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">}</span><br></pre></td></tr></table></figure>
<a class="article-more-a" href="/2019/08/30/基本类型的++操作原理/#more">more >></a>
</div>
<div class="article-info article-info-index">
<div class="article-tag tagcloud">
<i class="icon-price-tags icon"></i>
<ul class="article-tag-list">
<li class="article-tag-list-item">
<a href="javascript:void(0)" class="js-tag article-tag-list-link color4">bytecode</a>
</li>
<li class="article-tag-list-item">
<a href="javascript:void(0)" class="js-tag article-tag-list-link color4">jvm</a>
</li>
</ul>
</div>
<p class="article-more-link">
<a class="article-more-a" href="/2019/08/30/基本类型的++操作原理/">展开全文 >></a>
</p>
<div class="clearfix"></div>
</div>
</div>
</article>
<aside class="wrap-side-operation">
<div class="mod-side-operation">
<div class="jump-container" id="js-jump-container" style="display:none;">
<a href="javascript:void(0)" class="mod-side-operation__jump-to-top">
<i class="icon-font icon-back"></i>
</a>
<div id="js-jump-plan-container" class="jump-plan-container" style="top: -11px;">
<i class="icon-font icon-plane jump-plane"></i>
</div>
</div>
</div>
</aside>
<article id="post-从字节码看i=i++和i=++i" class="article article-type-post article-index" itemscope itemprop="blogPost">
<div class="article-inner">
<header class="article-header">
<h1 itemprop="name">
<a class="article-title" href="/2019/08/27/从字节码看i=i++和i=++i/">从字节码看i=i++和i=++i;</a>
</h1>
<a href="/2019/08/27/从字节码看i=i++和i=++i/" class="archive-article-date">
<time datetime="2019-08-27T01:32:07.000Z" itemprop="datePublished"><i class="icon-calendar icon"></i>2019-08-27</time>
</a>
</header>
<div class="article-entry" itemprop="articleBody">
<h4 id="对于i"><a href="#对于i" class="headerlink" title="对于i++"></a>对于i++</h4><p>源码:</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">int</span> <span class="title">plus</span><span class="params">()</span></span>{</span><br><span class="line"> <span class="keyword">int</span> i=<span class="number">0</span>;</span><br><span class="line"> i=i++;</span><br><span class="line"> <span class="keyword">return</span> i;</span><br><span class="line">}</span><br></pre></td></tr></table></figure>
<p>字节码:</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">public int test();</span><br><span class="line"> Code:</span><br><span class="line"> 0: iconst_1 //int类型 1 放入栈顶</span><br><span class="line"> 1: istore_1 //栈顶int类型数值放入局部变量表第二个位置 </span><br><span class="line"> 2: iload_1 //将局部变量表第二个位置数据放入栈顶</span><br><span class="line"> 3: iinc 1, 1 //将局部变量表第二个位置的元素+1</span><br><span class="line"> 6: istore_1 //将栈顶元素放入局部变量表第二个位置</span><br><span class="line"> 7: iload_1 //将局部变量表第二个位置的值放入栈顶</span><br><span class="line"> 8: ireturn //将栈顶元素返回</span><br></pre></td></tr></table></figure>
<p>注:局部变量表的第一个位置留给this</p>
<a class="article-more-a" href="/2019/08/27/从字节码看i=i++和i=++i/#more">more >></a>
</div>
<div class="article-info article-info-index">
<div class="article-tag tagcloud">
<i class="icon-price-tags icon"></i>
<ul class="article-tag-list">
<li class="article-tag-list-item">
<a href="javascript:void(0)" class="js-tag article-tag-list-link color4">bytecode</a>
</li>
<li class="article-tag-list-item">
<a href="javascript:void(0)" class="js-tag article-tag-list-link color4">jvm</a>
</li>
</ul>
</div>
<p class="article-more-link">
<a class="article-more-a" href="/2019/08/27/从字节码看i=i++和i=++i/">展开全文 >></a>
</p>
<div class="clearfix"></div>
</div>
</div>
</article>
<aside class="wrap-side-operation">
<div class="mod-side-operation">
<div class="jump-container" id="js-jump-container" style="display:none;">
<a href="javascript:void(0)" class="mod-side-operation__jump-to-top">
<i class="icon-font icon-back"></i>
</a>
<div id="js-jump-plan-container" class="jump-plan-container" style="top: -11px;">
<i class="icon-font icon-plane jump-plane"></i>
</div>
</div>
</div>
</aside>
<article id="post-java逆向总结" class="article article-type-post article-index" itemscope itemprop="blogPost">
<div class="article-inner">
<header class="article-header">
<h1 itemprop="name">
<a class="article-title" href="/2019/08/23/java逆向总结/">java逆向总结</a>
</h1>
<a href="/2019/08/23/java逆向总结/" class="archive-article-date">
<time datetime="2019-08-23T04:26:14.000Z" itemprop="datePublished"><i class="icon-calendar icon"></i>2019-08-23</time>
</a>
</header>
<div class="article-entry" itemprop="articleBody">
<p>毕竟是第一次进行逆向,过程中有许多乱七八糟的,也走了很多弯路,不过说到底还是学习了一些东西的;</p>
<p>比如逆向的时候要搞清楚函数的返回值啊,调用链啊,这地方可能就需要AspectJ了,然后获取到返回值之后,还要对代码进行具体的分析,方法返回什么值?,这地方可能就要顺着作者的思路了。</p>
<p>还有就是修改字节码的时候,有些能比较清晰地看到类方法的基本上可以用javasisst直接插入方法体就行了,但是如果没办法反编译的话只能用ASM把字节码修改了;也可以javassist组合起来用,比如用javassist给类加个打印异常日志的方法write,然后利用ASM在捕获到异常的时候把异常用write(Exception)打印到文件里,这样就可以更好分析插件了。</p>
<p>ZKM混淆之后的字节码基本上都是a,b,c,d啥的,所有的字符串也变成了</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">//加密方法</span><br><span class="line">a(int,int);</span><br><span class="line">//或者字符串数组</span><br><span class="line">static final String[] a;</span><br></pre></td></tr></table></figure>
<p>看得脑仁疼;</p>
<p>反编译也用了cfr,jad,jbytemod之类的工具;</p>
<p>但对于没办法反编译到java代码的只能硬生生地看字节码了;</p>
<p>刚好也更熟悉了字节码的一些指令,之前就只大概知道字节码怎么看,像异常表之类的就不熟很熟悉,还有本地变量表也是;</p>
<p>总的来说还是对自己有些提高的把,虽然也花了一些时间。但至少明白了字节码,切面代理之类的东西。</p>
</div>
<div class="article-info article-info-index">
<div class="article-tag tagcloud">
<i class="icon-price-tags icon"></i>
<ul class="article-tag-list">
<li class="article-tag-list-item">
<a href="javascript:void(0)" class="js-tag article-tag-list-link color5">逆向工程</a>
</li>
</ul>
</div>
<p class="article-more-link">
<a class="article-more-a" href="/2019/08/23/java逆向总结/">展开全文 >></a>
</p>
<div class="clearfix"></div>
</div>
</div>
</article>
<aside class="wrap-side-operation">
<div class="mod-side-operation">
<div class="jump-container" id="js-jump-container" style="display:none;">
<a href="javascript:void(0)" class="mod-side-operation__jump-to-top">
<i class="icon-font icon-back"></i>
</a>
<div id="js-jump-plan-container" class="jump-plan-container" style="top: -11px;">
<i class="icon-font icon-plane jump-plane"></i>
</div>
</div>
</div>
</aside>
<article id="post-Java逆向记录(三),ASM的使用" class="article article-type-post article-index" itemscope itemprop="blogPost">
<div class="article-inner">
<header class="article-header">
<h1 itemprop="name">
<a class="article-title" href="/2019/08/23/Java逆向记录(三),ASM的使用/">Java逆向记录(三),ASM的使用</a>
</h1>
<a href="/2019/08/23/Java逆向记录(三),ASM的使用/" class="archive-article-date">
<time datetime="2019-08-23T04:04:37.000Z" itemprop="datePublished"><i class="icon-calendar icon"></i>2019-08-23</time>
</a>
</header>
<div class="article-entry" itemprop="articleBody">
<h4 id="分析"><a href="#分析" class="headerlink" title="分析"></a>分析</h4><p>之前的招不太管用,然后只能从字节码下手,分析之后字符串混淆的字节码基本是</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">SIPUSH xxxx</span><br><span class="line">SIPUSH xxxx</span><br><span class="line">INVOKESTATIC a(int,int)String;</span><br></pre></td></tr></table></figure>
<p>这种形式,于是打算使用ASM修改字节码,将这一段改成具体的字符串入栈,即:</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">LDC "xxxxxx"</span><br></pre></td></tr></table></figure>
<p>修改字节码时,并没有使用原始的ClassVisitor和MethodVisitor,而是使用ClassNode和MethodNode,以迭代器的形式进行遍历:</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">test</span><span class="params">(String className)</span> <span class="keyword">throws</span> Exception </span>{</span><br><span class="line"> ClassReader reader = <span class="keyword">new</span> ClassReader(className);</span><br><span class="line"> ClassNode classNode = <span class="keyword">new</span> ClassNode();</span><br><span class="line"> reader.accept(classNode, ClassReader.EXPAND_FRAMES);</span><br><span class="line"> <span class="keyword">final</span> List<MethodNode> methods = classNode.methods;</span><br><span class="line"> <span class="keyword">for</span> (MethodNode methodNode : methods) {</span><br><span class="line"> <span class="keyword">final</span> ListIterator<AbstractInsnNode> iterator = methodNode.instructions.iterator();</span><br><span class="line"> <span class="keyword">while</span> (iterator.hasNext()) {</span><br><span class="line"> <span class="keyword">final</span> AbstractInsnNode sipush1 = iterator.next();</span><br><span class="line"> <span class="keyword">if</span> (sipush1 <span class="keyword">instanceof</span> IntInsnNode) {</span><br><span class="line"> <span class="comment">//这地方主要是判断字节是否是SIPUSH,SIPUSH,INVOKESTATIC的形式</span></span><br><span class="line"> <span class="keyword">if</span> (sipush1.getOpcode() == SIPUSH && iterator.hasNext()) {</span><br><span class="line"> <span class="keyword">final</span> AbstractInsnNode siPush2 = sipush1.getNext();</span><br><span class="line"> <span class="keyword">final</span> AbstractInsnNode invokeStatic = siPush2.getNext();</span><br><span class="line"> <span class="keyword">if</span> (sipush1.getOpcode() == siPush2.getOpcode() &&</span><br><span class="line"> invokeStatic.getOpcode() == INVOKESTATIC) {</span><br><span class="line"> <span class="keyword">int</span> v1 = ((IntInsnNode) sipush1).operand;</span><br><span class="line"> <span class="keyword">int</span> v2 = ((IntInsnNode) siPush2).operand;</span><br><span class="line"> <span class="keyword">final</span> String value1 = getValue(className, v1, v2);</span><br><span class="line"> <span class="keyword">if</span> (value1 == <span class="keyword">null</span>) {</span><br><span class="line"> <span class="keyword">continue</span>;</span><br><span class="line"> }</span><br><span class="line"> System.out.println(<span class="string">" do replace... ["</span> + value1 + <span class="string">"] in "</span> + className);</span><br><span class="line"> iterator.remove();</span><br><span class="line"> iterator.next();</span><br><span class="line"> iterator.remove();</span><br><span class="line"> iterator.next();</span><br><span class="line"> iterator.set(<span class="keyword">new</span> LdcInsnNode(value1));</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> ClassWriter writer = <span class="keyword">new</span> ClassWriter(ClassWriter.COMPUTE_FRAMES);</span><br><span class="line"> classNode.accept(writer);</span><br><span class="line"> <span class="keyword">final</span> <span class="keyword">byte</span>[] bytes1 = writer.toByteArray();</span><br><span class="line"> <span class="comment">//write to file ....</span></span><br><span class="line">}</span><br></pre></td></tr></table></figure>
<h4 id="遇到的坑"><a href="#遇到的坑" class="headerlink" title="遇到的坑"></a>遇到的坑</h4><p>其中遇到的坑大概是设置ASM修改级别的时候,使用ASM5级别的时候会导致修改lambda报错。</p>
<p>还有就是设置ClassReader的<strong>ClassReader.EXPAND_FRAMES</strong> 和ClassWriter的<strong>ClassWriter.COMPUTE_FRAMES</strong>,搞不好会搞混了。</p>
</div>
<div class="article-info article-info-index">
<div class="article-tag tagcloud">
<i class="icon-price-tags icon"></i>
<ul class="article-tag-list">
<li class="article-tag-list-item">
<a href="javascript:void(0)" class="js-tag article-tag-list-link color5">Java</a>
</li>
<li class="article-tag-list-item">
<a href="javascript:void(0)" class="js-tag article-tag-list-link color4">ASM</a>
</li>
<li class="article-tag-list-item">
<a href="javascript:void(0)" class="js-tag article-tag-list-link color4">bytecode</a>
</li>
</ul>
</div>
<p class="article-more-link">
<a class="article-more-a" href="/2019/08/23/Java逆向记录(三),ASM的使用/">展开全文 >></a>
</p>
<div class="clearfix"></div>
</div>
</div>
</article>
<aside class="wrap-side-operation">
<div class="mod-side-operation">
<div class="jump-container" id="js-jump-container" style="display:none;">
<a href="javascript:void(0)" class="mod-side-operation__jump-to-top">
<i class="icon-font icon-back"></i>
</a>
<div id="js-jump-plan-container" class="jump-plan-container" style="top: -11px;">
<i class="icon-font icon-plane jump-plane"></i>
</div>
</div>
</div>
</aside>
<article id="post-Java逆向记录(二),Javassist的使用" class="article article-type-post article-index" itemscope itemprop="blogPost">
<div class="article-inner">
<header class="article-header">
<h1 itemprop="name">
<a class="article-title" href="/2019/08/23/Java逆向记录(二),Javassist的使用/">Java逆向记录(二),Javassist的使用</a>
</h1>
<a href="/2019/08/23/Java逆向记录(二),Javassist的使用/" class="archive-article-date">
<time datetime="2019-08-23T04:04:27.000Z" itemprop="datePublished"><i class="icon-calendar icon"></i>2019-08-23</time>
</a>
</header>
<div class="article-entry" itemprop="articleBody">
<h4 id="思路:修改目标代码"><a href="#思路:修改目标代码" class="headerlink" title="思路:修改目标代码"></a>思路:修改目标代码</h4><p>在分析了字符串之后,找到了一些关键字符串,比如验证,发送激活请求后的代表激活信息的JsonObject,随后用javassist进行修改</p>
<figure class="highlight groovy"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//gradle/maven 引入依赖</span></span><br><span class="line">compile <span class="string">group:</span> <span class="string">'org.javassist'</span>, <span class="string">name:</span> <span class="string">'javassist'</span>, <span class="string">version:</span> <span class="string">'3.25.0-GA'</span></span><br></pre></td></tr></table></figure>
<h4 id="具体代码"><a href="#具体代码" class="headerlink" title="具体代码"></a>具体代码</h4><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">@Test</span></span><br><span class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">modify</span><span class="params">()</span> <span class="keyword">throws</span> NotFoundException, CannotCompileException, IOException </span>{</span><br><span class="line"> <span class="keyword">final</span> ClassPool pool = ClassPool.getDefault();</span><br><span class="line"> <span class="keyword">final</span> CtClass ctClass = pool.get(<span class="string">"要修改的类"</span>);</span><br><span class="line"> <span class="comment">//需要修改的方法</span></span><br><span class="line"> <span class="keyword">final</span> CtMethod d = ctClass.getDeclaredMethods(<span class="string">"d"</span>)[<span class="number">1</span>];</span><br><span class="line"> <span class="keyword">final</span> CtMethod a = ctClass.getDeclaredMethods(<span class="string">"a"</span>)[<span class="number">2</span>];</span><br><span class="line"> <span class="keyword">final</span> CtMethod b = ctClass.getDeclaredMethods(<span class="string">"b"</span>)[<span class="number">2</span>];</span><br><span class="line"> <span class="comment">//方法体写在 {} 内部,其中,类需要写全限定名,即:Date类需要写java.util.Date</span></span><br><span class="line"> d.setBody(</span><br><span class="line"> <span class="string">"{\n"</span> +</span><br><span class="line"> <span class="string">" Response res = new Response();\n"</span> +</span><br><span class="line"> <span class="string">" res.setValid(Boolean.valueOf(true));\n"</span> +</span><br><span class="line"> <span class="string">" res.setEncrptString(\"3.1415926\");\n"</span> +</span><br><span class="line"> <span class="string">" return res;\n"</span> +</span><br><span class="line"> <span class="string">" }\n"</span> +</span><br><span class="line"> <span class="string">" "</span>);</span><br><span class="line"> a.setBody(<span class="string">"{return true;}"</span>);</span><br><span class="line"> <span class="comment">//$1,代表方法的第一个参数</span></span><br><span class="line"> b.setBody(<span class="string">"{$1.setValid(true);$1.k(new java.util.Date(2099,1,1,1,1));super.b($1);}"</span>);</span><br><span class="line"> <span class="comment">//写入文件</span></span><br><span class="line"> ctClass.toBytecode(<span class="keyword">new</span> DataOutputStream(<span class="keyword">new</span> FileOutputStream(<span class="string">"D:/a.class"</span>)));</span><br><span class="line">}</span><br></pre></td></tr></table></figure>
<p>插入 错误日志打印方法 </p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">CtMethod method = CtMethod.make(<span class="string">"public static void write(Exception e) {\n"</span> +</span><br><span class="line"> <span class="string">" java.io.File file = new java.io.File(\"D:/error.log\");\n"</span> +</span><br><span class="line"> <span class="string">" try {\n"</span> +</span><br><span class="line"> <span class="string">" if (!file.exists()) {\n"</span> +</span><br><span class="line"> <span class="string">" file.createNewFile();\n"</span> +</span><br><span class="line"> <span class="string">" }\n"</span> +</span><br><span class="line"> <span class="string">" e.printStackTrace(new java.io.PrintStream(new java.io.FileOutputStream(file)));\n"</span> +</span><br><span class="line"> <span class="string">" } catch (java.io.IOException ex) {\n"</span> +</span><br><span class="line"> <span class="string">" ex.printStackTrace();\n"</span> +</span><br><span class="line"> <span class="string">" }\n"</span> +</span><br><span class="line"> <span class="string">" }"</span>, ctClass);</span><br><span class="line">ctClass.addMethod(method);</span><br><span class="line">ctClass.toBytecode(<span class="keyword">new</span> DataOutputStream(<span class="keyword">new</span> FileOutputStream(<span class="string">"D:/b.class"</span>)));</span><br></pre></td></tr></table></figure>
<h4 id="遇到的坑"><a href="#遇到的坑" class="headerlink" title="遇到的坑"></a>遇到的坑</h4><p>遇到的坑大概是写类的时候得写全路径名,然后方法体必须包含在{}内部</p>
</div>
<div class="article-info article-info-index">
<div class="article-tag tagcloud">
<i class="icon-price-tags icon"></i>
<ul class="article-tag-list">
<li class="article-tag-list-item">
<a href="javascript:void(0)" class="js-tag article-tag-list-link color5">Java</a>
</li>
<li class="article-tag-list-item">
<a href="javascript:void(0)" class="js-tag article-tag-list-link color5">javassist</a>
</li>
</ul>
</div>
<p class="article-more-link">
<a class="article-more-a" href="/2019/08/23/Java逆向记录(二),Javassist的使用/">展开全文 >></a>
</p>
<div class="clearfix"></div>
</div>
</div>
</article>
<aside class="wrap-side-operation">
<div class="mod-side-operation">
<div class="jump-container" id="js-jump-container" style="display:none;">
<a href="javascript:void(0)" class="mod-side-operation__jump-to-top">
<i class="icon-font icon-back"></i>
</a>
<div id="js-jump-plan-container" class="jump-plan-container" style="top: -11px;">
<i class="icon-font icon-plane jump-plane"></i>
</div>
</div>