0%

网络爬虫逆向(乌海市公共资源交易中心)

目标网址:https://jzsc.mohurd.gov.cn/data/company

爬取目标:

  • 统一社会信用代码
  • 企业名称
  • 企业法定代表人
  • 企业注册属地

image-20230410162715940

难点:数据包内容被加密

网页解析

首先,清空网络选项中所有的数据包

image-20230410154151229

然后,打开开发者工具,然后点击下一页,发现在网络中多出了一个数据包

image-20230410154234710

查看数据包内容

image-20230410154316592

发现数据包被加密

然后,点击启动器

image-20230410154643525

发现启动器中有很多异步加载的关键字,说明该数据包很可能是通过Ajax进行渲染加载的。

Ajax渲染出来的数据一般需要使用JSON.parse()进行解析,在此我们可以利用这个特征对数据包进行筛选。

刷新页面,在网络中搜索JSON.parse

image-20230410154935179

可以发现有两个JS文件被筛选出来了。

  • app.a9ab633d.js
  • chunk-vendors.ff342e34.js

具体是通过哪个JS文件进行解密的还需要进一步筛选,这个时候我们打开数据包的标头。

image-20230410155156363

可以看到数据包的请求网址为:https://jzsc.mohurd.gov.cn/APi/webApi/dataservice/query/comp/list?pg=0&pgsz=15&total=0

我们挑选网址中的webApi在网络中进行搜索。

image-20230410155304907

可以发现现在只有一个JS文件被筛选出来了。

找到该JS文件,右键点击在来源面板中打开

image-20230410155350977

然后在该JS文件中搜索JSON.parse

image-20230410155610010

发现在该JS文件中一共搜索到了两条记录。

给这两条记录打上断点,然后刷新网页。

image-20230410155745554

可以初步的看到h函数是用来解密data数据的。

光标放到h函数上定位到该函数具体位置。

image-20230410155940940

新建JS文件,将h函数内容复制到JS文件中。

1
2
3
4
5
6
7
8
9
10
11
12
13
function h(t) {
var e = d.a.enc.Hex.parse(t)
, n = d.a.enc.Base64.stringify(e)
, a = d.a.AES.decrypt(n, f, {
iv: m,
mode: d.a.mode.CBC,
padding: d.a.pad.Pkcs7
})
, r = a.toString(d.a.enc.Utf8);
return r.toString()
}
data = '95780ba0943730051dccb5fe3918f9fe1b6f2130681f99d5620c5497aa480f13f32e8cc4b2f871a9a59a1d0117ce9456ce6b66396085eaa2822aa2ffc121eac1885d297bbd68dcda88cd8b0b29e282f9fd6b8392d52b817608665d8a565119f3346fb19449490842b923ec5781524595bc078b2c15e47473f15860e2ed45c9dbab5a750581a26fcb22b99228eb09b541e83ac3724f373a7512ac3827fa40354d1e9af350488194daf6b0317870a9a65dee320e0d4cb84708b25e383c02095c17f20d09fb39ab6e1a150c85818ecc2a31c384412859eff0026319094965cffffbc42c9495ee35f03b2440b8baac751927c38b616dc2042a64223fa6a72f1dc685fcbb38fd7cc47f1efbc9f5bd2c7490e58fbd36cf5a3b4be852fac87c6e682bb7d554b9990431e2d550d914754c6ac899fef97980084a6ba4bfda771be81ea11fd1542b6ffafe1439be2c94f74f6a83bfce6d2bc2e9dc1d86b84eeb85c2b8dda8846d65232148f9d88ac4a675d2049c1ac6efae1e4a5f4a106f0e627fb89199d9491303a792672832269e9a5cc208be00fbf1baf342262ebdbef5eaf3a50a52eeae2811f2813697018bf103df428dc0d496af435d2384b2198000add245d87233c3955695a6daa1bb4bc5a8657b2c9dfbf9f4067097df759f5724a5cb3a747a58509e2f22da6cbcdd29ba95dc555cd40cba6d0a2eced0b15ece067bc949dce784b2ceb06a61e9f7dc8943445da701c15fc7053f2c21ea1fc877e02280d22f913983c6f1dead091312c37aa90a5967b71b4c34dab24468bde5f747d8f44f8fd4b0fa493ff49b92441a7e1e8c256a6a18573baa1bf16f5093e36a7c9e282a3156dba776ea6a94794c9a034ae4f5e77761e49569d194d10703302476e7fd8e25ab4669f0c7a6c7d0e2680847d77ea5a585f7f60e7fcebb1ae791b8216bb25b644f5094157bd62c6aebf0a7faf173b2fde0da6f9ebb0dcab8a129c11b9f972445aee5297d38e0cc72d0b4d9c84c7e6b0ecf592d37998d04df8c52d5776c2741863b5fefd69302f176909b6bc065c4b81fc959a348368d250a03a86145f81950937ca83e3a765e6afd71d00c68faeca8d4d76f5ad762fc7d17fd05894857841bec355bb1d7f75db95c8e30dea58536ac6288fd3429ca9ab48d1eddb48631734ce2a574d79b93952fa2c9e9665c6337b35ea2309344cd22fe1b92dbd02051917d6c5edf1f2259c5f8a0cb3fbd00391c298f0461ba16a2300337d0b60b224bc6b796cedeb427cd07d97f17460d490bc3b112d2b8403026ff5ff5a70dde82cf210f22c3c206ca3bfe34cc137bedad0f1ae712d7168226a42fd22f9e17dede40654157e4c4756bd10292c7d0e2eefba36634309aeb24d3725802243e2003a68dac0a3b539eed0dca51f6f0d57a5c58a117fc56910d0e7319b05e0fc4a5137952e2f958636b584973da7dd61b63101e2d0cffe2b249c562b72b64fb6ca67ed0246bf0f9185fe22c87dc6d3c8374239dd4e70cdbc5ccacbd359dea203c021ac7d54998b2f1571d7f787a3ce1c4fda45037bd33be1ff9da883a556e2ef81ad2047d35a5065e73402e0e02231bcb3724445df198ad53112db4690091a98edea0fd194480b4193c2e9bb1cee1fb37654fce593cc88c59537003dd297be5d88834ec00595a4dda9fe44e14193482f1d212cf33ec58be3edfbecf7c7908bbf4c4b9beee5d0ef148e1bbdae9daea30beadcc6f5639a6f4eb57719fda5bc0e8766a52da34f17f2aa1a4b608fb6e53938d8e74d3b53aaeee663e1053e8444d44fb7a782d3b087155c9341559ada772299b988e859039435751592c25532090c0cc1a4445ba93ab3a1c9e8cd198251ed3ed76cc5091b83ead3cf1e11ceeeb0461e923c394a0a9f37220b9a5ed8e5f01b360eb6661a6456cde6a4497186567d4324d469277be217c03b84048ad272a3ea49b943f4c7c70487d060cd24cd9ea61032207c2a13c1384e0b5159d70d78d5e224401b5142ca2548ff2a13d1029a3b54dd68c7ac03d2c004c645ea586cdebf96267fffac4079305e37ab11e3af6bdff0e296ee4b5efdd00b48f44a91eb8475ddd6668a0b7548a7640229aeb650f76e02005b782a0a082175f256654aa8e0f3e3675726c9697978fd4ac35b6b64107e373cf80a9881152e62b2c1841292dbc40c41a7a36c8d353f2add2731415dcd81be8b3cdbfe26dec973a4e6edf2382992409db93aea8f354fbea21a21c54747ac540e752b5b13fee5f5d30277de7178eb998e31656b266c4de884a878251d6108ef36bfe8ec1020cbd469debe57478fb3af6d369a6e12499ba5ee436cef3f3089aa1710a0ddf84809875b5fb0cf1ee1aedbb25e0df0617f1ec2b6bea1671d2adf79a7d6789b019218bcc7219cb9a53f47dcffccd129a48cebb2433fa9d7e547a651a09c2bf4637639d2c08aee3d7e10d2b2474e1a4ecc22e932cddfd6c4caa781af8eed3a8ff0a261ae116e134b76b7e5d084ba242b0a109b424e4e74d0a0018290b491a97e571977e09d79047ddd510dd7102548a14b04938cac79c15a7e03a4ed64f69168b93a5ad5608a3edf433363f07fa601383566b537230df6a46c073ec472e7be790a92af7db67d1334cd1098fa339cfe858e759f918c6bed01402cce8aa43512ce1a9208531edfe16ae743aaf5357587372e248a68d7d33698764d05234a19d84c1566e4e96d13457f8d273609ced3662356687a65ee59868325334883ea21552dacb8b8bbafe68b98ba402b6ddbdfa0040f0dc5fafa02b9ebb7216ab7443b3bd4580a207c3a6beca773d061ea384908a23d739adbbc690a7dd5ec67d59bc9025a6ba708d8d7c63785acc455e1fe6e6a3acf46f9786c12100db59c71f32b5648804cdb40cca356cd5bf8503f12e30eb575a440fa115539d53ee5f6e8269260cdc2e825b408726dd74953a11914a17e263f8355fb0df890f605856f65837d87b70262e6ad03e21f947d154a9f99cd1b904eb72065dc03b449233597b2072ab1b6ea3d408017b9a21eba679633fb88381346a6193ae9a0bab1c16bb8e8a53d75b3c1746b504ed0c45be0694d115ae012109ada0dad961ad107e3c2568fe5baa57e18267399421056f1c1e63feef5e50ec3a89d9507212f3eea0140e8cb52499356d033e07452deebdb7d8ed03106c22b294dc6fa50ca8114855a238418d6a914a633d5835085ac004f35c41e65fcae25d155b338eabfc98e01483d4e00fdcb0caae3e8f544dcedc90bd1393a426aafbe6d98d4a016cbb9097c01f3153d05659f382366f36f025283fac809fc7322898964aeac267bd323981d59afad32568e40ff006cdadeeb18e6ba7a9fb9956f878f10e6fc028e005bfb50feb3accdc6c14e5f7237f996a8cb2599a42bd0ccff426f6dcf087d3a97d0120e4383e62d81eea5d73b7b43e41d5251d329f228168f12437f67cbf420bf2d2b71dd67b8523cfdbd219d1c7251d148e42aa1ecd42e8693516047b0abb47d3ffaf83945c9f6a17a248d7aceb42e2af242701d8d239ac0f6c2035768474f0e7801a9584191e40042d6b410b3b9d40cd436396f1c1b68eaf6b21e3e6494984d640a54563ced6fd020c8ccbae41e9eddd68a3f174e7495db3bdd4a2f8b7f38aa9631aa4bde9567b4526d851b071b95e7af042cbecd6b4d78fc89958c93bac5b68d30761628dfe10a908600b98b65e8b7a5b3067cd1aaa57d3d3f8942e08ef5891aae7012d2f5fe30bb8153d615814ef6e35ce4f1de79848e1b623b399bbbc07ba6ec56e1d5fd9ba184d3ac31d74b5645ba29088575d06915586ea7c789d942f04641af94a873aba213e4de646c466011c26af27b10406a852bd2cb9a3f4bc818f2555dd6187ba9249dea59985b50d0902dd9f3dedc45c1a8056d4feaaf94878bd8c6b1aeefb7baec6018c843559a54cdfcf0571c92cedc137682002bb29188eb0b3f37849c2d0cfc63e26f3dccd38ca23070a6b43f651780dcbe82453bfe22d2af70225c9cde8bb6070bb4934aa45f9eabf2443336b9160eae8c4f4ecf34a5483fe354996f2ea03d5003d8005f99c721f6b3df1c662345b1717df8ecd650d1cb1be67ef03c85c96d0b8f9b98b31a48c81a11bd95832652985f27eea0ff0d1d4a2d4b9b80c301d2f5f5aceedebde590a2fbcd0c3aea6f092b6b14b2bf638f36b7a84c8bff4aa5c968679d47bc5ff5851a8aede8b408e38c15f0dd828ba41bdeece59f228e69e65bf3765be1d8b2674b602c108b2e01c37986994d261b03fd22a418d24092f75df8ff1add8538bce478b24e74d1d8d1a00371579144ed729b5b148149373de8edc5d421f286fef1e1718c37f2aadbdbaddd058e8f9ff7f14e9bd37cc7cfc78a70cadc71330f9aeae2cbfd73c5dc4931eb060032a955ddcd74fd88bb948db78e2bba24f0fa79106684654ee65e287335bc07069bb7da8602cb0cf195451c4bdc25ba40838a37239b42c4c0422e2eff334fbe65603f7b2698528b5d2dac3ace7366e42af15b5e9420273ad342110f873fe8b8fb503d7e1dff071d86f8c41372afa05398ef0378479367ef55634aeadcd115512ec13f69d8f703b7ea5189679c78d76da8bde66a272c21ef12b8f3d262d6f00b0fd9ec2d49e50f0564bbfee942007e6f3d57dff860af818f8d84a416902f9be306a6a16fd4004f3410ca591ea9e039b6652d60c71ea4f018c54f91f0f0580e4f92aef97776d76173f10dd4f7a00f7545dd2a564a31ecb44267cfe5c0f05d929813f6f49d64e104a631b6f48813c3e363a2d045688a158564b4c7909a53a40736e80e641fcbb7140eafb42113f8a8fccb304ca4b8c0c5d4c085beb70e9b86ea4365ec674be41b94be15a95205615380df50ea99f7b3be063af4b338dbede597c7a4b620d8cc7a92bcd302ec0193fded07ddac7b9b6286578defaef9bfb78ac1f5b0f3f3a7b04c8bc90e74b110f54ca0ec99cf18fa2c4ab32b258e5ad50c8ebedef6bc4065375ec985dd253de043d44b11702462d3b52fd933e0dc2c4a5c85b64eb71585f8c8b884ac35e25ce29b5faa8a56143db1e9582d6c0041ee95eb1b309ca1b25338dad55a2ad6cd724f357adaf50a04fe34d2ac868b25783bcb26ed6b9b349b0649261063e3cbd0bc7164280f690f73b41e5c60d54459714e7fc24c529568afeb53c5fc1556f95283db3cd00d1d655212a7859186f657672305bdda28e40d15f11b7ae4d038ab63214f93a0bb40d0badebe492566ed6c9a0ea86652f924437185bc09ac3b86b1953e1e3c15de68bf32977cc479063bb8d436a9a1c60d8e012a44aebfb14c9c42e9eabc13a5eeeb329d007701ff19316e02c795627e7c391821a1f2e1254594a49c7727d683187095403ef7ff4a24f773492fc454cd1c583f1abd409ed82f2d4106a97bd35645684c486fb2f6800940f24708d4c5a7f17b2fdc75d9259a32efb3e62494b8fdec9dd48905810b2bd67fe30a6dc89cafb5a1e72c64a325d4f0f27898b9bd3a88d95661c7dda699562fd7a7a1de5d325d7e4de19274250add5bd9a92ffdb62709e2b3ab667bec4891fdfb1849ca1fe6030464842d9a798a55fa40d0b8c9854d8416e6bd45d474f5beac902f462f7d29873ce8688859555a7a5e7a58a42f0b777e5354785db94fc09b862f86236ed42f2dc40e6d534c9a2c3983595137177d1427c2cf18e4cf9a77ad25b5b6f26ad08562e96fa3a37f9874f875caed57d786b931f369d54c72b5c833133599e6abdc4206f049962d236f10ee05c96ed77371d92df69fa35dbb6fa1751c4df970317430c0d680f434d5fe365bd4eeaf4165037c3976463cae7bc6d7ad587779b6f0251e5eb56e5fee645fae414a7203aa62eaee13b2e9801716769c55e394b3f4cbb6e82544e4969c487e8b02b17fd429d67aa80e24a75ad8d9756202cc8e74380a4acfc875193eba7f6e4a3672411bd6636cb2296fcc4908caf444a8e9768f81382d01b2087461e69b45cd1e3aae3b70f834f786b9af2c32664243fa5ef5c7ed53e76c3c503af61a9fedd2dfbb3fa97598779b9df3066f394e55359e4540da927a2765f48bd2e4d4a2ce3913d88606ac3fbcbfd07dede3a9b0deb9fbfa143cd97c4f8b99c30cd6f2b14acc2eb5a4fce2218461d80412ce9a8a652136a5ee900999c679199759fd8fc98d792b4a02280bfe6'
console.log(h(data))

运行JS文件,查看需要补充哪些函数和变量。

image-20230410160204167

可以发现d函数没有,接下来回到h函数,观察代码发现有很多地方调用了d.a.这个库,经过观察该库的调用方式和调用函数,d.a.库来源于前端加密JS库CryptoJS

可以使用以下方式进行下载:

1
npm install crypto-js

下载完毕后在JS文件中使用以下代码进行导入

1
const CryptoJS = require('crypto-js')

然后将代码中所有的d.a.修改为CryptoJS

修改后的代码为

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
const CryptoJS = require('crypto-js')


function h(t) {
var e = CryptoJS.enc.Hex.parse(t)
, n = CryptoJS.enc.Base64.stringify(e)
, a = CryptoJS.AES.decrypt(n, f, {
iv: m,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7
})
, r = a.toString(CryptoJS.enc.Utf8);
return r.toString()
}

data = '95780ba0943730051dccb5fe3918f9fe1b6f2130681f99d5620c5497aa480f13f32e8cc4b2f871a9a59a1d0117ce9456ce6b66396085eaa2822aa2ffc121eac1885d297bbd68dcda88cd8b0b29e282f9fd6b8392d52b817608665d8a565119f3346fb19449490842b923ec5781524595bc078b2c15e47473f15860e2ed45c9dbab5a750581a26fcb22b99228eb09b541e83ac3724f373a7512ac3827fa40354d1e9af350488194daf6b0317870a9a65dee320e0d4cb84708b25e383c02095c17f20d09fb39ab6e1a150c85818ecc2a31c384412859eff0026319094965cffffbc42c9495ee35f03b2440b8baac751927c38b616dc2042a64223fa6a72f1dc685fcbb38fd7cc47f1efbc9f5bd2c7490e58fbd36cf5a3b4be852fac87c6e682bb7d554b9990431e2d550d914754c6ac899fef97980084a6ba4bfda771be81ea11fd1542b6ffafe1439be2c94f74f6a83bfce6d2bc2e9dc1d86b84eeb85c2b8dda8846d65232148f9d88ac4a675d2049c1ac6efae1e4a5f4a106f0e627fb89199d9491303a792672832269e9a5cc208be00fbf1baf342262ebdbef5eaf3a50a52eeae2811f2813697018bf103df428dc0d496af435d2384b2198000add245d87233c3955695a6daa1bb4bc5a8657b2c9dfbf9f4067097df759f5724a5cb3a747a58509e2f22da6cbcdd29ba95dc555cd40cba6d0a2eced0b15ece067bc949dce784b2ceb06a61e9f7dc8943445da701c15fc7053f2c21ea1fc877e02280d22f913983c6f1dead091312c37aa90a5967b71b4c34dab24468bde5f747d8f44f8fd4b0fa493ff49b92441a7e1e8c256a6a18573baa1bf16f5093e36a7c9e282a3156dba776ea6a94794c9a034ae4f5e77761e49569d194d10703302476e7fd8e25ab4669f0c7a6c7d0e2680847d77ea5a585f7f60e7fcebb1ae791b8216bb25b644f5094157bd62c6aebf0a7faf173b2fde0da6f9ebb0dcab8a129c11b9f972445aee5297d38e0cc72d0b4d9c84c7e6b0ecf592d37998d04df8c52d5776c2741863b5fefd69302f176909b6bc065c4b81fc959a348368d250a03a86145f81950937ca83e3a765e6afd71d00c68faeca8d4d76f5ad762fc7d17fd05894857841bec355bb1d7f75db95c8e30dea58536ac6288fd3429ca9ab48d1eddb48631734ce2a574d79b93952fa2c9e9665c6337b35ea2309344cd22fe1b92dbd02051917d6c5edf1f2259c5f8a0cb3fbd00391c298f0461ba16a2300337d0b60b224bc6b796cedeb427cd07d97f17460d490bc3b112d2b8403026ff5ff5a70dde82cf210f22c3c206ca3bfe34cc137bedad0f1ae712d7168226a42fd22f9e17dede40654157e4c4756bd10292c7d0e2eefba36634309aeb24d3725802243e2003a68dac0a3b539eed0dca51f6f0d57a5c58a117fc56910d0e7319b05e0fc4a5137952e2f958636b584973da7dd61b63101e2d0cffe2b249c562b72b64fb6ca67ed0246bf0f9185fe22c87dc6d3c8374239dd4e70cdbc5ccacbd359dea203c021ac7d54998b2f1571d7f787a3ce1c4fda45037bd33be1ff9da883a556e2ef81ad2047d35a5065e73402e0e02231bcb3724445df198ad53112db4690091a98edea0fd194480b4193c2e9bb1cee1fb37654fce593cc88c59537003dd297be5d88834ec00595a4dda9fe44e14193482f1d212cf33ec58be3edfbecf7c7908bbf4c4b9beee5d0ef148e1bbdae9daea30beadcc6f5639a6f4eb57719fda5bc0e8766a52da34f17f2aa1a4b608fb6e53938d8e74d3b53aaeee663e1053e8444d44fb7a782d3b087155c9341559ada772299b988e859039435751592c25532090c0cc1a4445ba93ab3a1c9e8cd198251ed3ed76cc5091b83ead3cf1e11ceeeb0461e923c394a0a9f37220b9a5ed8e5f01b360eb6661a6456cde6a4497186567d4324d469277be217c03b84048ad272a3ea49b943f4c7c70487d060cd24cd9ea61032207c2a13c1384e0b5159d70d78d5e224401b5142ca2548ff2a13d1029a3b54dd68c7ac03d2c004c645ea586cdebf96267fffac4079305e37ab11e3af6bdff0e296ee4b5efdd00b48f44a91eb8475ddd6668a0b7548a7640229aeb650f76e02005b782a0a082175f256654aa8e0f3e3675726c9697978fd4ac35b6b64107e373cf80a9881152e62b2c1841292dbc40c41a7a36c8d353f2add2731415dcd81be8b3cdbfe26dec973a4e6edf2382992409db93aea8f354fbea21a21c54747ac540e752b5b13fee5f5d30277de7178eb998e31656b266c4de884a878251d6108ef36bfe8ec1020cbd469debe57478fb3af6d369a6e12499ba5ee436cef3f3089aa1710a0ddf84809875b5fb0cf1ee1aedbb25e0df0617f1ec2b6bea1671d2adf79a7d6789b019218bcc7219cb9a53f47dcffccd129a48cebb2433fa9d7e547a651a09c2bf4637639d2c08aee3d7e10d2b2474e1a4ecc22e932cddfd6c4caa781af8eed3a8ff0a261ae116e134b76b7e5d084ba242b0a109b424e4e74d0a0018290b491a97e571977e09d79047ddd510dd7102548a14b04938cac79c15a7e03a4ed64f69168b93a5ad5608a3edf433363f07fa601383566b537230df6a46c073ec472e7be790a92af7db67d1334cd1098fa339cfe858e759f918c6bed01402cce8aa43512ce1a9208531edfe16ae743aaf5357587372e248a68d7d33698764d05234a19d84c1566e4e96d13457f8d273609ced3662356687a65ee59868325334883ea21552dacb8b8bbafe68b98ba402b6ddbdfa0040f0dc5fafa02b9ebb7216ab7443b3bd4580a207c3a6beca773d061ea384908a23d739adbbc690a7dd5ec67d59bc9025a6ba708d8d7c63785acc455e1fe6e6a3acf46f9786c12100db59c71f32b5648804cdb40cca356cd5bf8503f12e30eb575a440fa115539d53ee5f6e8269260cdc2e825b408726dd74953a11914a17e263f8355fb0df890f605856f65837d87b70262e6ad03e21f947d154a9f99cd1b904eb72065dc03b449233597b2072ab1b6ea3d408017b9a21eba679633fb88381346a6193ae9a0bab1c16bb8e8a53d75b3c1746b504ed0c45be0694d115ae012109ada0dad961ad107e3c2568fe5baa57e18267399421056f1c1e63feef5e50ec3a89d9507212f3eea0140e8cb52499356d033e07452deebdb7d8ed03106c22b294dc6fa50ca8114855a238418d6a914a633d5835085ac004f35c41e65fcae25d155b338eabfc98e01483d4e00fdcb0caae3e8f544dcedc90bd1393a426aafbe6d98d4a016cbb9097c01f3153d05659f382366f36f025283fac809fc7322898964aeac267bd323981d59afad32568e40ff006cdadeeb18e6ba7a9fb9956f878f10e6fc028e005bfb50feb3accdc6c14e5f7237f996a8cb2599a42bd0ccff426f6dcf087d3a97d0120e4383e62d81eea5d73b7b43e41d5251d329f228168f12437f67cbf420bf2d2b71dd67b8523cfdbd219d1c7251d148e42aa1ecd42e8693516047b0abb47d3ffaf83945c9f6a17a248d7aceb42e2af242701d8d239ac0f6c2035768474f0e7801a9584191e40042d6b410b3b9d40cd436396f1c1b68eaf6b21e3e6494984d640a54563ced6fd020c8ccbae41e9eddd68a3f174e7495db3bdd4a2f8b7f38aa9631aa4bde9567b4526d851b071b95e7af042cbecd6b4d78fc89958c93bac5b68d30761628dfe10a908600b98b65e8b7a5b3067cd1aaa57d3d3f8942e08ef5891aae7012d2f5fe30bb8153d615814ef6e35ce4f1de79848e1b623b399bbbc07ba6ec56e1d5fd9ba184d3ac31d74b5645ba29088575d06915586ea7c789d942f04641af94a873aba213e4de646c466011c26af27b10406a852bd2cb9a3f4bc818f2555dd6187ba9249dea59985b50d0902dd9f3dedc45c1a8056d4feaaf94878bd8c6b1aeefb7baec6018c843559a54cdfcf0571c92cedc137682002bb29188eb0b3f37849c2d0cfc63e26f3dccd38ca23070a6b43f651780dcbe82453bfe22d2af70225c9cde8bb6070bb4934aa45f9eabf2443336b9160eae8c4f4ecf34a5483fe354996f2ea03d5003d8005f99c721f6b3df1c662345b1717df8ecd650d1cb1be67ef03c85c96d0b8f9b98b31a48c81a11bd95832652985f27eea0ff0d1d4a2d4b9b80c301d2f5f5aceedebde590a2fbcd0c3aea6f092b6b14b2bf638f36b7a84c8bff4aa5c968679d47bc5ff5851a8aede8b408e38c15f0dd828ba41bdeece59f228e69e65bf3765be1d8b2674b602c108b2e01c37986994d261b03fd22a418d24092f75df8ff1add8538bce478b24e74d1d8d1a00371579144ed729b5b148149373de8edc5d421f286fef1e1718c37f2aadbdbaddd058e8f9ff7f14e9bd37cc7cfc78a70cadc71330f9aeae2cbfd73c5dc4931eb060032a955ddcd74fd88bb948db78e2bba24f0fa79106684654ee65e287335bc07069bb7da8602cb0cf195451c4bdc25ba40838a37239b42c4c0422e2eff334fbe65603f7b2698528b5d2dac3ace7366e42af15b5e9420273ad342110f873fe8b8fb503d7e1dff071d86f8c41372afa05398ef0378479367ef55634aeadcd115512ec13f69d8f703b7ea5189679c78d76da8bde66a272c21ef12b8f3d262d6f00b0fd9ec2d49e50f0564bbfee942007e6f3d57dff860af818f8d84a416902f9be306a6a16fd4004f3410ca591ea9e039b6652d60c71ea4f018c54f91f0f0580e4f92aef97776d76173f10dd4f7a00f7545dd2a564a31ecb44267cfe5c0f05d929813f6f49d64e104a631b6f48813c3e363a2d045688a158564b4c7909a53a40736e80e641fcbb7140eafb42113f8a8fccb304ca4b8c0c5d4c085beb70e9b86ea4365ec674be41b94be15a95205615380df50ea99f7b3be063af4b338dbede597c7a4b620d8cc7a92bcd302ec0193fded07ddac7b9b6286578defaef9bfb78ac1f5b0f3f3a7b04c8bc90e74b110f54ca0ec99cf18fa2c4ab32b258e5ad50c8ebedef6bc4065375ec985dd253de043d44b11702462d3b52fd933e0dc2c4a5c85b64eb71585f8c8b884ac35e25ce29b5faa8a56143db1e9582d6c0041ee95eb1b309ca1b25338dad55a2ad6cd724f357adaf50a04fe34d2ac868b25783bcb26ed6b9b349b0649261063e3cbd0bc7164280f690f73b41e5c60d54459714e7fc24c529568afeb53c5fc1556f95283db3cd00d1d655212a7859186f657672305bdda28e40d15f11b7ae4d038ab63214f93a0bb40d0badebe492566ed6c9a0ea86652f924437185bc09ac3b86b1953e1e3c15de68bf32977cc479063bb8d436a9a1c60d8e012a44aebfb14c9c42e9eabc13a5eeeb329d007701ff19316e02c795627e7c391821a1f2e1254594a49c7727d683187095403ef7ff4a24f773492fc454cd1c583f1abd409ed82f2d4106a97bd35645684c486fb2f6800940f24708d4c5a7f17b2fdc75d9259a32efb3e62494b8fdec9dd48905810b2bd67fe30a6dc89cafb5a1e72c64a325d4f0f27898b9bd3a88d95661c7dda699562fd7a7a1de5d325d7e4de19274250add5bd9a92ffdb62709e2b3ab667bec4891fdfb1849ca1fe6030464842d9a798a55fa40d0b8c9854d8416e6bd45d474f5beac902f462f7d29873ce8688859555a7a5e7a58a42f0b777e5354785db94fc09b862f86236ed42f2dc40e6d534c9a2c3983595137177d1427c2cf18e4cf9a77ad25b5b6f26ad08562e96fa3a37f9874f875caed57d786b931f369d54c72b5c833133599e6abdc4206f049962d236f10ee05c96ed77371d92df69fa35dbb6fa1751c4df970317430c0d680f434d5fe365bd4eeaf4165037c3976463cae7bc6d7ad587779b6f0251e5eb56e5fee645fae414a7203aa62eaee13b2e9801716769c55e394b3f4cbb6e82544e4969c487e8b02b17fd429d67aa80e24a75ad8d9756202cc8e74380a4acfc875193eba7f6e4a3672411bd6636cb2296fcc4908caf444a8e9768f81382d01b2087461e69b45cd1e3aae3b70f834f786b9af2c32664243fa5ef5c7ed53e76c3c503af61a9fedd2dfbb3fa97598779b9df3066f394e55359e4540da927a2765f48bd2e4d4a2ce3913d88606ac3fbcbfd07dede3a9b0deb9fbfa143cd97c4f8b99c30cd6f2b14acc2eb5a4fce2218461d80412ce9a8a652136a5ee900999c679199759fd8fc98d792b4a02280bfe6'
console.log(h(data))

重新运行JS代码

image-20230410161824542

发现f未找到。

然后在浏览器JS代码中找到f对应内容。

image-20230410161957490

复制到JS文件中的h函数中,并将d.a.修改为CryptoJS

同样,m也在h函数中也不存在,按照相同的方式将m也找到,并放入JS文件中。

最后JS代码修改为

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
const CryptoJS = require('crypto-js')


function h(t) {
var f = CryptoJS.enc.Utf8.parse("jo8j9wGw%6HbxfFn")
var m = CryptoJS.enc.Utf8.parse("0123456789ABCDEF");
var e = CryptoJS.enc.Hex.parse(t)
, n = CryptoJS.enc.Base64.stringify(e)
, a = CryptoJS.AES.decrypt(n, f, {
iv: m,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7
})
, r = a.toString(CryptoJS.enc.Utf8);
return r.toString()
}

data = '95780ba0943730051dccb5fe3918f9fe1b6f2130681f99d5620c5497aa480f13f32e8cc4b2f871a9a59a1d0117ce9456ce6b66396085eaa2822aa2ffc121eac1885d297bbd68dcda88cd8b0b29e282f9fd6b8392d52b817608665d8a565119f3346fb19449490842b923ec5781524595bc078b2c15e47473f15860e2ed45c9dbab5a750581a26fcb22b99228eb09b541e83ac3724f373a7512ac3827fa40354d1e9af350488194daf6b0317870a9a65dee320e0d4cb84708b25e383c02095c17f20d09fb39ab6e1a150c85818ecc2a31c384412859eff0026319094965cffffbc42c9495ee35f03b2440b8baac751927c38b616dc2042a64223fa6a72f1dc685fcbb38fd7cc47f1efbc9f5bd2c7490e58fbd36cf5a3b4be852fac87c6e682bb7d554b9990431e2d550d914754c6ac899fef97980084a6ba4bfda771be81ea11fd1542b6ffafe1439be2c94f74f6a83bfce6d2bc2e9dc1d86b84eeb85c2b8dda8846d65232148f9d88ac4a675d2049c1ac6efae1e4a5f4a106f0e627fb89199d9491303a792672832269e9a5cc208be00fbf1baf342262ebdbef5eaf3a50a52eeae2811f2813697018bf103df428dc0d496af435d2384b2198000add245d87233c3955695a6daa1bb4bc5a8657b2c9dfbf9f4067097df759f5724a5cb3a747a58509e2f22da6cbcdd29ba95dc555cd40cba6d0a2eced0b15ece067bc949dce784b2ceb06a61e9f7dc8943445da701c15fc7053f2c21ea1fc877e02280d22f913983c6f1dead091312c37aa90a5967b71b4c34dab24468bde5f747d8f44f8fd4b0fa493ff49b92441a7e1e8c256a6a18573baa1bf16f5093e36a7c9e282a3156dba776ea6a94794c9a034ae4f5e77761e49569d194d10703302476e7fd8e25ab4669f0c7a6c7d0e2680847d77ea5a585f7f60e7fcebb1ae791b8216bb25b644f5094157bd62c6aebf0a7faf173b2fde0da6f9ebb0dcab8a129c11b9f972445aee5297d38e0cc72d0b4d9c84c7e6b0ecf592d37998d04df8c52d5776c2741863b5fefd69302f176909b6bc065c4b81fc959a348368d250a03a86145f81950937ca83e3a765e6afd71d00c68faeca8d4d76f5ad762fc7d17fd05894857841bec355bb1d7f75db95c8e30dea58536ac6288fd3429ca9ab48d1eddb48631734ce2a574d79b93952fa2c9e9665c6337b35ea2309344cd22fe1b92dbd02051917d6c5edf1f2259c5f8a0cb3fbd00391c298f0461ba16a2300337d0b60b224bc6b796cedeb427cd07d97f17460d490bc3b112d2b8403026ff5ff5a70dde82cf210f22c3c206ca3bfe34cc137bedad0f1ae712d7168226a42fd22f9e17dede40654157e4c4756bd10292c7d0e2eefba36634309aeb24d3725802243e2003a68dac0a3b539eed0dca51f6f0d57a5c58a117fc56910d0e7319b05e0fc4a5137952e2f958636b584973da7dd61b63101e2d0cffe2b249c562b72b64fb6ca67ed0246bf0f9185fe22c87dc6d3c8374239dd4e70cdbc5ccacbd359dea203c021ac7d54998b2f1571d7f787a3ce1c4fda45037bd33be1ff9da883a556e2ef81ad2047d35a5065e73402e0e02231bcb3724445df198ad53112db4690091a98edea0fd194480b4193c2e9bb1cee1fb37654fce593cc88c59537003dd297be5d88834ec00595a4dda9fe44e14193482f1d212cf33ec58be3edfbecf7c7908bbf4c4b9beee5d0ef148e1bbdae9daea30beadcc6f5639a6f4eb57719fda5bc0e8766a52da34f17f2aa1a4b608fb6e53938d8e74d3b53aaeee663e1053e8444d44fb7a782d3b087155c9341559ada772299b988e859039435751592c25532090c0cc1a4445ba93ab3a1c9e8cd198251ed3ed76cc5091b83ead3cf1e11ceeeb0461e923c394a0a9f37220b9a5ed8e5f01b360eb6661a6456cde6a4497186567d4324d469277be217c03b84048ad272a3ea49b943f4c7c70487d060cd24cd9ea61032207c2a13c1384e0b5159d70d78d5e224401b5142ca2548ff2a13d1029a3b54dd68c7ac03d2c004c645ea586cdebf96267fffac4079305e37ab11e3af6bdff0e296ee4b5efdd00b48f44a91eb8475ddd6668a0b7548a7640229aeb650f76e02005b782a0a082175f256654aa8e0f3e3675726c9697978fd4ac35b6b64107e373cf80a9881152e62b2c1841292dbc40c41a7a36c8d353f2add2731415dcd81be8b3cdbfe26dec973a4e6edf2382992409db93aea8f354fbea21a21c54747ac540e752b5b13fee5f5d30277de7178eb998e31656b266c4de884a878251d6108ef36bfe8ec1020cbd469debe57478fb3af6d369a6e12499ba5ee436cef3f3089aa1710a0ddf84809875b5fb0cf1ee1aedbb25e0df0617f1ec2b6bea1671d2adf79a7d6789b019218bcc7219cb9a53f47dcffccd129a48cebb2433fa9d7e547a651a09c2bf4637639d2c08aee3d7e10d2b2474e1a4ecc22e932cddfd6c4caa781af8eed3a8ff0a261ae116e134b76b7e5d084ba242b0a109b424e4e74d0a0018290b491a97e571977e09d79047ddd510dd7102548a14b04938cac79c15a7e03a4ed64f69168b93a5ad5608a3edf433363f07fa601383566b537230df6a46c073ec472e7be790a92af7db67d1334cd1098fa339cfe858e759f918c6bed01402cce8aa43512ce1a9208531edfe16ae743aaf5357587372e248a68d7d33698764d05234a19d84c1566e4e96d13457f8d273609ced3662356687a65ee59868325334883ea21552dacb8b8bbafe68b98ba402b6ddbdfa0040f0dc5fafa02b9ebb7216ab7443b3bd4580a207c3a6beca773d061ea384908a23d739adbbc690a7dd5ec67d59bc9025a6ba708d8d7c63785acc455e1fe6e6a3acf46f9786c12100db59c71f32b5648804cdb40cca356cd5bf8503f12e30eb575a440fa115539d53ee5f6e8269260cdc2e825b408726dd74953a11914a17e263f8355fb0df890f605856f65837d87b70262e6ad03e21f947d154a9f99cd1b904eb72065dc03b449233597b2072ab1b6ea3d408017b9a21eba679633fb88381346a6193ae9a0bab1c16bb8e8a53d75b3c1746b504ed0c45be0694d115ae012109ada0dad961ad107e3c2568fe5baa57e18267399421056f1c1e63feef5e50ec3a89d9507212f3eea0140e8cb52499356d033e07452deebdb7d8ed03106c22b294dc6fa50ca8114855a238418d6a914a633d5835085ac004f35c41e65fcae25d155b338eabfc98e01483d4e00fdcb0caae3e8f544dcedc90bd1393a426aafbe6d98d4a016cbb9097c01f3153d05659f382366f36f025283fac809fc7322898964aeac267bd323981d59afad32568e40ff006cdadeeb18e6ba7a9fb9956f878f10e6fc028e005bfb50feb3accdc6c14e5f7237f996a8cb2599a42bd0ccff426f6dcf087d3a97d0120e4383e62d81eea5d73b7b43e41d5251d329f228168f12437f67cbf420bf2d2b71dd67b8523cfdbd219d1c7251d148e42aa1ecd42e8693516047b0abb47d3ffaf83945c9f6a17a248d7aceb42e2af242701d8d239ac0f6c2035768474f0e7801a9584191e40042d6b410b3b9d40cd436396f1c1b68eaf6b21e3e6494984d640a54563ced6fd020c8ccbae41e9eddd68a3f174e7495db3bdd4a2f8b7f38aa9631aa4bde9567b4526d851b071b95e7af042cbecd6b4d78fc89958c93bac5b68d30761628dfe10a908600b98b65e8b7a5b3067cd1aaa57d3d3f8942e08ef5891aae7012d2f5fe30bb8153d615814ef6e35ce4f1de79848e1b623b399bbbc07ba6ec56e1d5fd9ba184d3ac31d74b5645ba29088575d06915586ea7c789d942f04641af94a873aba213e4de646c466011c26af27b10406a852bd2cb9a3f4bc818f2555dd6187ba9249dea59985b50d0902dd9f3dedc45c1a8056d4feaaf94878bd8c6b1aeefb7baec6018c843559a54cdfcf0571c92cedc137682002bb29188eb0b3f37849c2d0cfc63e26f3dccd38ca23070a6b43f651780dcbe82453bfe22d2af70225c9cde8bb6070bb4934aa45f9eabf2443336b9160eae8c4f4ecf34a5483fe354996f2ea03d5003d8005f99c721f6b3df1c662345b1717df8ecd650d1cb1be67ef03c85c96d0b8f9b98b31a48c81a11bd95832652985f27eea0ff0d1d4a2d4b9b80c301d2f5f5aceedebde590a2fbcd0c3aea6f092b6b14b2bf638f36b7a84c8bff4aa5c968679d47bc5ff5851a8aede8b408e38c15f0dd828ba41bdeece59f228e69e65bf3765be1d8b2674b602c108b2e01c37986994d261b03fd22a418d24092f75df8ff1add8538bce478b24e74d1d8d1a00371579144ed729b5b148149373de8edc5d421f286fef1e1718c37f2aadbdbaddd058e8f9ff7f14e9bd37cc7cfc78a70cadc71330f9aeae2cbfd73c5dc4931eb060032a955ddcd74fd88bb948db78e2bba24f0fa79106684654ee65e287335bc07069bb7da8602cb0cf195451c4bdc25ba40838a37239b42c4c0422e2eff334fbe65603f7b2698528b5d2dac3ace7366e42af15b5e9420273ad342110f873fe8b8fb503d7e1dff071d86f8c41372afa05398ef0378479367ef55634aeadcd115512ec13f69d8f703b7ea5189679c78d76da8bde66a272c21ef12b8f3d262d6f00b0fd9ec2d49e50f0564bbfee942007e6f3d57dff860af818f8d84a416902f9be306a6a16fd4004f3410ca591ea9e039b6652d60c71ea4f018c54f91f0f0580e4f92aef97776d76173f10dd4f7a00f7545dd2a564a31ecb44267cfe5c0f05d929813f6f49d64e104a631b6f48813c3e363a2d045688a158564b4c7909a53a40736e80e641fcbb7140eafb42113f8a8fccb304ca4b8c0c5d4c085beb70e9b86ea4365ec674be41b94be15a95205615380df50ea99f7b3be063af4b338dbede597c7a4b620d8cc7a92bcd302ec0193fded07ddac7b9b6286578defaef9bfb78ac1f5b0f3f3a7b04c8bc90e74b110f54ca0ec99cf18fa2c4ab32b258e5ad50c8ebedef6bc4065375ec985dd253de043d44b11702462d3b52fd933e0dc2c4a5c85b64eb71585f8c8b884ac35e25ce29b5faa8a56143db1e9582d6c0041ee95eb1b309ca1b25338dad55a2ad6cd724f357adaf50a04fe34d2ac868b25783bcb26ed6b9b349b0649261063e3cbd0bc7164280f690f73b41e5c60d54459714e7fc24c529568afeb53c5fc1556f95283db3cd00d1d655212a7859186f657672305bdda28e40d15f11b7ae4d038ab63214f93a0bb40d0badebe492566ed6c9a0ea86652f924437185bc09ac3b86b1953e1e3c15de68bf32977cc479063bb8d436a9a1c60d8e012a44aebfb14c9c42e9eabc13a5eeeb329d007701ff19316e02c795627e7c391821a1f2e1254594a49c7727d683187095403ef7ff4a24f773492fc454cd1c583f1abd409ed82f2d4106a97bd35645684c486fb2f6800940f24708d4c5a7f17b2fdc75d9259a32efb3e62494b8fdec9dd48905810b2bd67fe30a6dc89cafb5a1e72c64a325d4f0f27898b9bd3a88d95661c7dda699562fd7a7a1de5d325d7e4de19274250add5bd9a92ffdb62709e2b3ab667bec4891fdfb1849ca1fe6030464842d9a798a55fa40d0b8c9854d8416e6bd45d474f5beac902f462f7d29873ce8688859555a7a5e7a58a42f0b777e5354785db94fc09b862f86236ed42f2dc40e6d534c9a2c3983595137177d1427c2cf18e4cf9a77ad25b5b6f26ad08562e96fa3a37f9874f875caed57d786b931f369d54c72b5c833133599e6abdc4206f049962d236f10ee05c96ed77371d92df69fa35dbb6fa1751c4df970317430c0d680f434d5fe365bd4eeaf4165037c3976463cae7bc6d7ad587779b6f0251e5eb56e5fee645fae414a7203aa62eaee13b2e9801716769c55e394b3f4cbb6e82544e4969c487e8b02b17fd429d67aa80e24a75ad8d9756202cc8e74380a4acfc875193eba7f6e4a3672411bd6636cb2296fcc4908caf444a8e9768f81382d01b2087461e69b45cd1e3aae3b70f834f786b9af2c32664243fa5ef5c7ed53e76c3c503af61a9fedd2dfbb3fa97598779b9df3066f394e55359e4540da927a2765f48bd2e4d4a2ce3913d88606ac3fbcbfd07dede3a9b0deb9fbfa143cd97c4f8b99c30cd6f2b14acc2eb5a4fce2218461d80412ce9a8a652136a5ee900999c679199759fd8fc98d792b4a02280bfe6'
console.log(h(data))

运行JS文件,返回结果正常。

image-20230410162225386

使用python调用JS代码

使用以下代码请求获取加密数据,并利用JS代码进行解析。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# -- coding: utf-8 --
"""
@Name: demo4.py
@Auth: Ming-Log
@Date: 2023/4/8-16:55
@Desc:
"""
# 全国建筑市场监督公共服务平台 https://jzsc.mohurd.gov.cn/data/company
import requests
import execjs
import json


api = 'https://jzsc.mohurd.gov.cn/APi/webApi/dataservice/query/comp/list'

params = {
'pg': 2,
'pgsz': 15,
'total': 450,
}
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36',
'Referer': 'https://jzsc.mohurd.gov.cn/data/company'

}
response = requests.get(api, params=params, headers=headers)
data = response.text

with open('demo4.js', 'r', encoding='UTF-8') as f:
jscode = f.read()

ctx = execjs.compile(jscode).call('h', data)
print(ctx)

运行时可能出现以下报错:

UnicodeDecodeError: ‘gbk‘ codec can‘t decode byte 0xad in position 47: illegal multibyte sequence

image-20230410162504885

解决办法:

点击进入subprocess.py包,搜索encoding,将encoding=None处修改为encoding='utf-8'

再次运行即可解决该问题。

-------------本文结束感谢您的阅读-------------