AutoCAD 3DMAX C語言 Pro/E UG JAVA編程 PHP編程 Maya動畫 Matlab應用 Android
Photoshop Word Excel flash VB編程 VC編程 Coreldraw SolidWorks A Designer Unity3D
 首頁 > Linux

inc文件使用的風險和注意事項

51自學網 http://www.0532cf.com
數據庫使用中需要關注的主要問題之一是訪問權限即用戶名及密碼的暴露。在編程中為了方便,一般都會用一個db.inc文件保存

代碼如下:
<?php
 $db_user = 'myuser';
$db_pass = 'mypass';
$db_host = '127.0.0.1';
 $db = mysql_connect($db_host, $db_user, $db_pass);
 ?>

用戶名及密碼都是敏感數據,是需要特別注意的。他們被寫在源碼中造成了風險,但這是一個無法避免的問題。如果不這么做,你的數據庫就無法設置用戶名和密碼進行保護了。
如果你讀過http.conf(Apache的配置文件)的默認版本的話,你會發現默認的文件類型是text/plain(普通文本)。這樣,如果db.inc這樣的文件被保存在網站根目錄下時,就引發了風險。所有位于網站根目錄下的資源都有相應的URL,由于Apache沒有定義對.inc后綴的文件的處理方式類型,在對這一類文件進行訪問時,會以普通文本的類型進行返回(默認類型),這樣訪問權限就被暴露在客戶的瀏覽器上了。
為了進一步說明這個風險,考慮一下一個以/www為網站根目錄的服務器,如果db.inc被保存在/www/inc,它有了一個自已的URL  http://example.org/inc/db.inc(假設example.org是主機域名)。通過訪問該URL就可以看到db.inc以文本方式顯示的源文件。無論你把該文件保存在/www哪個子目錄下,都無法避免訪問權限暴露的風險。
對這個問題最好的解決方案是把它保存在網站根目錄以外的包含目錄中。你無需為了達到包含它們的目的而把它們放至在文件系統中的特定位置,所有只要做的只是保證Web服務器對其有讀取權限。因此,把它們放在網站根目錄下是沒有必要的風險,只要包含文件還位于網站根目錄下,任何減少風險的努力都是徒勞的。事實上,你只要把必須要通過URL訪問的資源放置在網站根目錄下即可。畢竟這是一個公共的目錄。
前面的話題對于SQLite數據庫也有用。把數據庫保存在當前目錄下是非常方便的,因為你只要調用文件名而無需指定路徑。但是,把數據庫保存在網站根目錄下就代表著不必要的風險。如果你沒有采用安全措施防止直接訪問的話,你的數據庫就危險了。
如果由于外部因素導致無法做到把所有包含文件放在網站根目錄之外,你可以在Apache配置成拒絕對.inc資源的請求。

代碼如下:
<Files ~ "/.inc$">
  Order allow,deny
  Deny from all
</Files>

如果只是因為要舉個例子而這么寫的話,可以理解,畢竟大家學到了一些手段,但這個例子未免生硬了一點。實際上只要把該文件更名為db.inc.php就可以了。就好象房子破了個洞而不去修補,卻在外面去造一個更大的房子把破房子套起來一樣。
后面你還可以看到另外一種防止數據庫訪問權限暴露的方法,該方法對于共享服務器環境(在該環境下盡管文件位于網站根目錄之外,但依然存在暴露的風險)非常有效。

 
上一篇:linux系統下ubuntu 中截圖工具及快捷鍵設置  下一篇:每個極客都應該知道的一些Linux技巧
彩客网 67890ii.com | y7064.com | www.am0676.com | www.kkwns.com | www.666118a.com | www.i94600.com | www.4444bj.com | www.669634.com | 88051.com | pj7686.com | www.0009193.com | www.06820i.com | www.6tdc.com | 89892yy.com | 8901k.com | www.pj5633.com | www.3399nsb.com | www.681090.com | 1064g.com | 6245s.com | www.c51kk.vip | www.68689f.com | 22299mm.com | 8037hhh.com | www.w88w118.com | www.8645006.com | www.557089.com | vip66657.com | www.3643l.com | www.60886z.com | www.536350.com | yun3399.co | www.ylg4444.com | www.1196877.com | www.9818a.cc | 3258v.com | www.85770m.com | www.ag4444.com | www.332910.com | 547842.com | www.s668839.com | www.78949f.com | 3644e.com | 58000d.com | www.298001.com | www.66376u.com | 62365.com | www.118sjz.cc | www.08992.com | 0241x.com | www.0805u.com | www.c79839.com | 19991o.com | www.cjcp456.com | www.ra017.com | 13222u.com | 670.cc | www.40339.com | 98kbc.com | 56988t.vip | www.9bet005.com | www.602436.com | 13879455.com | www.06820k.com | 3betbet365.com | www.76543e.com | www.919699.com | 8901.com | www.036888.com | www.qmfc8.com | 5651i.com | www.055888.com | www.810895.com | 3667.com | www.91gwa.com | www.691063.com | 2698j.com | www.4102p.com | 5856mmm.com | www.4972ww.com | www.66653j.com | 915905208.com | www.4078z.com | 118888j.com | cp088d.com | www.66332j.com | 4036tt.com | www.1754n.com | 7570.am | www.v0020.com | www.87668w.com | 095.com | www.00772o.com | 1679dd.com | www.mgm512.com | 4066z.com | www.16297799.com | www.372918.com | 69990e.com | www.87171.cc | BY30832.com | www.sss2848.com | bet36500220.com | www.508987.com | pj13339.com | www.495w.cc | www.911203.com | zhcp96.com | www.1206.com | 34f35.com | www.7920b.com | 67890i.com | www.biying910vip.com | 4018ii.com | www.38138t.com | 4123oo.com | www.288988b.com | www.hg864.com | qjdc555.com | www.0010013.com | www.21365aa.com | 3656nn.com | www.340477.com | www.50732l.com | www.38345h.com | www.hg313.com | 6118k.com | 66671n.com | v93902.com | www.zcwf6.com | www.993956.com | www.89599v.com | www.32666o.com | 4647044.com | 00048o.com | www.394077.com | www.8499n.com | www.91779p.com | www.554198.com | www.7658800.com | 3435c.com | 53262qq.com | xpj90618.com | www.310195.com | www.34788m.com | www.4408598.com | www.353303.com | www.k4737.com | 47749u.com | 86226m.com | 3950z.com | 0860j.com | 2613n.com | www.322424.com | www.qilc3.com | www.77802d.com | www.flb877.com | www.808888.tw | www.59909.com | www.935365.com | 5443.com | feicai0754.com | ii3405.com | 143547.com | 1168p.com | dj0009.com | 9789886.com | www.802865.com | www.9155a.com | www.00840e.com | www.68993278.com | www.4988a.cc | www.288sb.21.sb | www.377666d.com | www.8473y.com | www.5504e.com | www.bh99o.com | www.222584.com | www.1990365.com | www.223456u.com | www.2221105.com | www.x4242.com | www.4996gl.com | www.19019p.com | www.hy9881.com | www.d948d.com | www.mng55.com | www.pp8996.com | www.8124l.com | www.js507713.com | www.bh33123.com | 3656gg.com | bwin8006.com | www.85770n.com | www.38200l.com | www.hg22888.net | www.207365.com | www.dy1188.com | www.00829n.com | www.00618v.com | www.2833555.com | www.pj3364.com | www.2605505.vip | www.bh99o.com | www.1111zx.com | www.70039x.com | www.28003.com | www.0477msc.com | www.766649.com | www.858958.com | www.4446ccc.com | www.4058uu.com | www.04567i.com | www.552181.com | www.a88002.com | www.js58678.com | www.5677758.com | www.rrqp222.com | www.9187x.com | www.6613644.com | www.9155d.com | www.954688.com | www.444246.com | www.347177.com | 139975.com | 00778m.com | 655660022.com | 35222d.com | 76886p.com | so77777.cc | hg77702.com | gbhs44.com | www.995o.net | www.55555yh.com | www.777jyh.com | www.jsdc9000.com | www.6482.com | www.914906.com | www.136025.com | 97618g.com | 5622z.com | 3405n.com | aa7742.com | am772.cc | 0080x.com | www.8494i.com | www.h509.com | www.b7b8.com | www.4833043.com | www.3479o.com | www.901593.com | 14891489.com | 4022f.com | 2535app.com | www.hg3733.com | www.39333.com | www.4996xn.com | www.xj778899.com | www.676477.com | bbb7570.com | 5443a.com | mg437700.com | 9411uuu.com | www.8124g.com | www.23277.com | www.80999.vip | www.7714b.com | www.66ffd.com | xpj66888.com | 2147002.com | 11955.com | www.88jt555.com | www.00618i.com | www.p63568.com | www.hw8889.com | www.326608.com | 3678.com | wx2211.com | www.22799.com | www.c9478.com | www.7240x.com | www.cp500.in | 28839j.com | 69441133.com | 3938ee.com | www.531msc.com | www.js58678.com | www.hy5507.com | 718012.com | 4465q.com | www.63877f.com | www.310935.com | www.x2788.com | www.696776.com | 0270098.com | 3304x.com | www.b36365.com | www.69567p.com | www.c5908.com | 3169r.com | 33ff8332.com | www.777444e.com | www.009289.com | www.2934c.com | www.96386v.com | 9479a3.com | www.bmw0055.com | www.505444.com | www.5856877.com | www.324229.com | 78666b.com | www.cp2y.com | www.4828448.com | www.slyl3.com | 9566257.com | 5443v.com | www.233113.com | www.790964.com | 6700000.cc | 8200d.com | www.81866u.com | www.328209.com | www.3890p.com | 2324ppp.com | 3169l.com | www.esb125.com | www.60108k.com | hjdc110.com | 44077m.com | www.dmgbet95.com | www.61233pp.com | 2019rr.cc | 55vn77.com | www.5146z2.com | www.989778.com | 364493.com | 1389tt.com | www.17784.com | www.889688.com | 66300vip17.com | www.995h.net | www.ylylc07.com | 0234oo.com | bet577n.com | www.158cai.com | www.gy11.com | 4052mm.com | www.yh33558.com | www.yun879.com | 6177010.com | 50026655.com | www.i063801.com | www.187397.com | 66671d.com | www.amdc0005.com | www.5086r.com | 2019.cc | www.87680w.com | www.37377h.com | 5647z.com | www.sjs06.com | www.a30666.com | www.luck808.com | 22299xx.com | www.zte333.com | www.981060.com | 51133r.com | www.jty449.com | www.lqc7.com | 1458t.com | www.8577k.cc | www.055.la | 77606wcom | www.99857.com | www.78wcp.com | 7n3777.com | www.10852a.com | www.gai06.com | 40033ooo.com | www.2945.com | www.318021.com | 214kf.com | www.163a66.com | www.376369.com | 0241.com | www.634505.net | 4774s.com | v9966.com | www.63800.com | 3327.com | www.vns6036.com | www.35155z.com | 074u7.com | www.ty143.com | www.764918.com | 40033f.com | www.353560.com | www.596035.com | 81366v.com | www.xj7002.com | feicai0475.com | www.xpj8898.com | www.77114m.com | 0343h.com | www.7335zz.com | www.348077.com | a77304.com | www.538445.com | 559649.com | www.166349.com | www.980205.com | w5429.com | www.383335.com | 4018j.com | www.3643t.com | www.8618aa.com | 67890lll.com | www.bwin940.co | 51200hh.com | www.xpj4464.com | www.987931.com | 55188.com | www.z94600.com | 3807vv.com | www.133774.com | www.362322.com | www.js31567.com | www.77114y.com | 22098s.com | www.1754e.com | 66300vip06.com | www.572433.com | www.608986.com | pj677k.com | www.61655h.com | 82365x.com | www.xpj1123.com | p61653.com | www.c44dd.com | 8742kk.com | www.4625gg.com | www.279556.com | www.32126r.net | www.gai20.com | 0066886.com | www.84499k.com | 4mgm.com | www.67kk.com | 234903.com | www.pj9030.com | 0667.com | www.815818.com | 37688u.com | www.6880ss.com | 33599bb.com | www.99113j.com | j7736.com | www.5049l.com | 5804s.com | www.6778msc.com | ee2205.com | www.224605.com | ribo60.cc | www.306444b.com | 30019n.com | www.a6389.com | www.52303i.com | www.3729.com | www.277739.com | www.362833.com | www.649770.com | www.zq.hk | www.370933.com | www.2846s.com | www.161570.com | www.vns956.com | 9964b.com | www.443344.com | tyc5504.com | www.03.bet | 2257016.com | www.26123kk.com | xg7111.com | www.880317.com | rrr5657.com | www.hb858.net | 009900k.com | www.2350o.com | www.js96333.com | www.599474.com | www.4853a.com | bet975.com | www.66.42.42.157 | js03.app | www.3846b.com | hh38648.com | www.08588z.com | www.6667727.com | www.503489.com | www.60582.com | 4833011.com | www.28000x.com | vipvip6666.com | www.13434d.com | 2709u.com | www.671075.com | www.9966145.com | 4880s.com | www.hg8tt.com | 7777c9.com | www.41518x.com | feicai0937.com | www.808793.com | www.9949x.com | hg999333q.com | www.06820o.com | 052979.com | www.qml3.com | www.hg4428.com | 18438444.com | www.js89w.vip | 3121ee.com | www.670665.com | www.32666l.com | 6137m.net | www.089728.com | 444hg.com | www.040416.com | www.67799.com | 9090gbh.com | www.08182.com | www.jd8866.com | 69111l.com | www.bwinyz14.com | c86811.com | www.768399.com | www.7736.com | 955.com | www.50024f.com | www.00829u.com | 3482k.com | www.984705.com | 8890822.com | 551567.com | www.666207.com | jjjj.com | www.77802i.com | www.00772u.com | 123444.com | www.370155.com | www.50999m.com | 20055599.com | www.509980.com | www.cp67773.com | 365vip99.co | www.689244.com | www.5966qqq.com | 634.cm | www.611026.com | www.68199.com | tt00558.com | www.918356a.com | www.dpcq2.hly.com | 3405dd.com | www.898418.com | www.41427.com | 2138001.com | www.544094.com | www.a92776.com | hcp5555.com | 1440999.com | www.213981.com | www.8520q.com | 0638.cn | www.hg99976.com | www.bj9093.com | xxx5144.com | www.axc5.com | www.799666r.com | 11005k.com | www.71399o.com | www.32031b.com | www.ag355.com | 9949b.com | www.99788k.com | www.882618.com | 8159u.cc | www.319989.com | www.js79905.com | www.56733w.com | 35252d.com | www.33598q.com | www.89790.com | 21052277.com | 32424f.com | www.42842810.com | www.284444.me | 40033zz.com | www.361979.com | www.5719f.com | www.67797i.com | 83378d.com | www.866546.com | www.57800g.com | www.505vns.com | 1654q.com | www.ya909.com | www.89.cc | 88850nn.com | 3y999.com | www.hy9996.com | www.9737oo.com | www.wns8828.com | jixiangfang.com | www.806375.com | www.38138t.com | www.bet3650314.com | 6118099.com | www.338082.com | www.5446j.com | www.142336.com | 908080d.com | 9421.com | www.07163m.com | www.tc1158.com | www.kima99.net | 2381o.com | www.330732.com | www.cb600.cc | www.0400005.com | 3121uu.com | 228888e.com | www.795535.com | www.99552uu.com | www.hg123300.com | 44ss8332.com | 771381.com | www.937016.com | www.v2894.com | www.hg5588l.com | 00048p.com | 996622dd.com | www.669307.com | www.cb500.cc | www.hg032.com | www.200448.com | 7508j.com | 20054466.com | www.7777hv.com | www.3066xx.com | www.hg2297.com | 11rr8332.com | 238228.com | www.108382.com | www.76520q.com | www.1111yh.vip | www.aa3143.com | v997.com | 3245e.com | www.51515b.com | www.33588h.com | www.299764.com | www.xpj9710.com | 71088.com | 3568ff.com | 52599f.com | www.669350.com | www.3a436.com | www.88166f.com | www.22gg940.com | 3178ff.com | 5448099.com | zz811.com | www.853053.com | www.35898b.com | www.feng68.com | www.vns55545.com | 22556t.com | 18438r.com | 500000359.com | www.756398.com | www.333682.com | www.00773v.com | www.701556.com | www.pj35555.com | 86811f.com | 3846aa.com | 5956988.com | www.658056.com | www.99638g.com | www.g063801.com | www.081168.net | www.9068dd.com | 2978.com | 8037ggg.com | 201855.com | 4338099.com | www.623190.com | www.34788r.com | www.55676v.com | www.7415t.com | www.88399c.com | www.67797j.com | 2595w.com | k60666.com | 88833.com | 1077ff.com | www.349177.com | www.flcb1.com | www.bet353653.com | www.8473m.com | www.hg8875.com | www.xxx2205.com | www.589234.com | 2061155.com | 4165t.com | 64111b.com | 1305777.com | 8036xx.com | www.192762.com | www.841077.com | www.8499c.com | www.pujing75.com | www.12136s.com | www.4078b.com | www.2945c.com | www.5577js.com | www.hgbet22.com | www.i32126.cc | 5004gg.com | 3122m.com | 50067f.com | 7599q.com | mayait.cn | 1705l.com | feicai0510.com | 3983012.com | r17.com | www.80065v.com | www.403189.com | www.807860.com | www.996546.com | www.11czj.com | www.9818v.cc | www.53900b.com | www.m77929.com | www.4331r.com | www.089638.com | www.55676n.com | www.3008553.com | www.77181.com | www.pj1707.com | www.7366009.com | www.sha8000.com | www.4446ccc.com | www.71071g.com | www.8967h.com | www.c747.com | www.499904.com | www.c46.com | www.58665f.com | www.5xcai.vip | www.58665l.com | www.dzcp7777.com | www.cp009x.com | www.983888b.com | www.99c51.com | www.79500r.com | www.808888u.com | www.8967h.com | www.16181x.com | www.bwinyz09.com | www.ao3399.com | www.6687z.com | www.pjh.com | www.66074.com | www.37377r.com | www.ya2019v.com | www.66332g.com | www.9149j.com | www.k795.com | www.825799.com | www.vip9587.com | www.2299nsb.com | www.5953188.com | www.hg3005.com | www.77801w.com | www.37439.cc | www.ct6678.com | www.717226.com | www.368518.com | www.89894u.com | 16690022.com | betvictor98.com | 118888s.com | YL18438.com | mmm4165.com | 4182006.com | 8901o.com | www.jd8866.com | www.330099i.com | www.hg8373.com | www.599248.com | www.c51jj.vip | www.35252b.com | www.111999qipai.com | www.99677w.com | www.585hc.com | www.594243.com | www.60123u.com | 3807pp.com | dianzi580.com | ii3405.com | 8577j.cc | www.ylg3099.com | www.6161msccom.com | www.20553311.com | www.19019y.com | www.792087.com | www.84499p.com | www.899465.com | www.36166e.com | 4411mmmm.com | 4018m.com | 30177788.com | www.28758n.com | www.rr8800.com | www.747855.com | www.yz7704.com | www.41518q.com | www.582833.com | 5804q.com | 2418f.com | 11884747.com | www.pj9087.com | www.hg0477.com | www.b35tt.com | www.1358003.com | www.sxyl8.com | www.77114u.com | 69111o.com | wnsr828.com | 2000524.com | www.cz3065.com | www.9737kk.com | www.55238f.com | www.8970.com | www.61655i.com | 7736o.com | 00rr8332.com | www.7669c.net | www.wi444.com | www.38775cc.com | www.6611a.cc | www.99638a.com | 00339193.com | 9649c.com | www.xpj2018.com | www.3533msc.com | www.4809m.com | www.c9218.com | x33v.vip | 3568ww.com | www.sbd444.net | www.858448.com | www.blr2244.com | www.c5963.com | 188.cc | 3890s.com | www.38200u.com | www.98923.com | www.37377a.com | www.652592.com | 56987mm.com | fll8.in | www.330099o.com | www.10999g.com | www.35918n.com | sss006.com | 746.com | www.0555hg.com | www.0241h.com | www.kywns.205115.com | www.452820.com | 8294p.com | feicai0534.com | www.hg7861.com | www.32326.com | www.711863.com | 5309678.com | spj80.net | www.kj151.com | www.68365q.com | www.673730.com | 8294x.com | 3178z.com | www.6787749.com | www.200900.com | www.191079.com | 555666.com | www.b3652.com | www.4972l.com | www.9155a.cc | 55818m.com | vipvip7777.com | www.hg72999.com | www.h6620.com | www.276608.com | 83378u.com | www.bt258.com | www.19k0048.com | www.cb3288.com | ttt444000.com | 444hg.com | www.c555.cc | www.7782z.com | 3267.com | 83377f.com | www.kb9996.com | www.50024g.com | 22pp8331.com | 0434377.com | www.5966iii.com | www.08588m.com | 8881240.com | 8905.com | www.915395.com | www.220v.cc | LXYL362.com | www.86611b.com | www.8887hj.com | www.912273.com | vns2.vip | www.4688111.com | www.621468.com | www.312180.com | hhgz0077.com | www.3170004.com | www.9646w.com | 0938mv.com | c51iggd.com | www.p3065.com | www.938905.com | 6150q.com | www.7622900.com | www.48330h.com | 0693i.com | 88am.cc | www.99113v.com | www.882358.com | 1166589.com | www.0805e.com | www.c79839.com | 6868003.cc | 159194.com | www.33678qq.com | www.220875.com | 4036ee.com | www.hg8452.com | www.33112.com | hg999333i.com | www.hg8728.net | www.78919c.com | 3544t.com | www.1869g.com | www.88325p.com | www.78949v.com | hg91778.com | www.16181d.com | www.500770.com | nn500d.com | www.55526d.com | www.840979.com | 3522hh.cc | www.328466.com | www.c3004.com | 477076.com | www.466799.com | www.okw4.com | 66671d.com | www.597567d.com | www.855762.com | 40033uuu.com | www.yifa325.com | www.631799.com | 998v.cc | www.4963tt.com | www.279556.com | hgyz11.com | www.593152.com | 55aa8331.com | www.k88875.com | www.amyhdc0000.com | zhcpll.com | www.87680u.com | www.50732c.com | 225605.com | www.2222092.com | www.757209.com | 55331ww.com | www.38138j.com | www.8499n.com | www.791651.com | 2146e.com | www.89599e.com | www.77210a.com | 87680q.com | www.725603.com | 916.com | www.8sands.com | www.013ac.com | 4022v.com | www.7415aa.com | 2021h.com | www.76060u.com | www.550021p.com | 22299uu.com | www.5566800.com | www.480840.com | 28483000.com | www.o94600.com | 6423r.com | www.411036.com | www.631259.com | 8827ww.com | www.668679.com | 4036dd.com | www.090051.com | www.223085.com | 88850gg.com | www.99638b.com | 66287u.com | www.3157e.com | 168cp-r.com | www.2078v.com | www.994948.com | 2934s.com | www.452.com | 99151j.com | www.77731w.com | vv38648.cc | www.9068ii.com | www.c1396.com | 2844.com | www.0967004.com | 6766mm.com | www.7415cc.com | 7779e.cc | www.88867.com | www.lcw997.com | www.tushan168.com | www.8039e.com | 77332007.com | www.8722.am | 9539012.com | www.71071m.com | 8520d.com | www.60486b.com | www.50080v.com | www.4972rr.com | www.811927.com | 58802x.com | www.05883.cc | 6389997.com | www.4833033.com | 4488jj.com | www.60886a.com | 33cc8332.com | www.848777p.com | 2836518.com | www.hyl8.com | v1781.com | www.qq599.com | 08119.net | www.8797aavv.com | www.178693.com | www.js520456.com | www.581860.com | www.vns994.cc | www.818897.com |