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技巧
彩客网 www.bet91481.com | www.9286803.com | www.620557.com | www.8768011.com | www.055969.com | www.76775e.com | www.54844.com | 0559hk.com | www.514177.com | www.vnsr2018g.com | 0296.com | www.357076.com | bwin5588.net | www.21202n.com | www.ylhg6868.com | www.80075v.com | www.449999.com | 118cai.cc | www.087i.com | 253501.com | www.510830.com | www.693suncity.com | 299.so | www.5647ii.com | www.6033x.com | 08530005.com | www.93955b.com | 678210.com | www.hm5522.com | www.a80065.com | 55899v.com | www.550022ee.com | 1592x.com | 69-xpj.com | www.5203666.com | 80368v.com | www.987581.com | www.bte33.com | 3950z.com | www.974209.com | www.653505.com | 47749a.com | www.b33668.com | 8827ww.com | www.001832.com | www.848777a.com | 85722.com | www.351587.com | www.yzcp2024.com | 01885h.com | www.599476.com | www.751cp33.com | z08199.com | www.598411.com | www.120048.com | 33318i.com | www.776511.com | 3644h.com | www.hg6778.com | 80892m.com | www.9960.cc | www.736suncity.com | 561633.com | www.846661.com | www.a81a.cc | y68147.com | www.031566.com | www.4996nm.com | 463wu.com | 08809.com | www.c33668.com | t365c.com | 1316131.com | www.hg274.com | www.vns0488.com | vn6588.com | www.5095l.com | www.ykylc05.com | 1331cc.com | www.693377.com | www.8694d.com | 143573.com | www.669zf.com | www.85857a.com | www.82142.com | 234905.com | www.x98478.com | www.09569i.com | 08778o.com | www.544242.com | www.4996qj.com | www.hg771122.com | 4340o.com | www.88xpj68.com | www.h7714.com | 3178nn.com | www.637012.com | www.4694h.com | 124058.com | 3356.com | www.c8704.com | www.1196877.com | www.86611n.com | t08199.com | www.603854.com | www.2507777.com | www.358012.com | 2214bb.com | www.39500e.com | 444b9.com | www.3552b.com | www.c555.cc | bb5144.com | 8884828.com | www.861803.com | www.46630.vip | www.hgbet55.com | 444000c.com | www.js00868.com | www.85413.com | 4036.com | vip1449.com | www.911750.com | www.88000xpj.com | www.80651a.com | 2649gg.com | www.313055.com | www.hg594.com | www.6574d.com | 5589i.com | js999js.com | www.234397.com | www.aobo190.com | www.esb125.com | www.hjcp4.com | 5099bb.com | www.188727.com | www.910021.com | www.77731u.com | www.28758a.com | 3535.cc | xh15555.com | www.799666a.com | e5429.com | 80892rr.com | www.638262.com | www.dsj11.com | www.rg5.com | www.7830k.com | 99151g.com | linxiangf.pw | yf2888.com | www.hj8987.com | www.blr5544.com | www.fbs33.com | www.df997.com | rrr40033.com | 66648v.com | www.208780.com | www.52005.cc | www.x22789.com | www.65886z.com | www.mmtx22.com | 30006q.com | yh77333.com | 76116666.com | www.096386.com | www.55587.com | www.ddd2848.com | www.hgw675.com | 2629.com | mry04.com | 98kbc.com | www.557595.com | www.0270n.com | www.j7764.com | www.140suncity.com | www.js80288.com | 32212c.com | 3775f.com | www.223559.com | www.c5905.com | www.173383.com | www.r32031.com | www.163a5.com | www.9939365.com | www.76543p.com | gbhs33.com | 70118e.com | 3807yy.com | 5003p.com | 80878g.com | www.84499e.com | www.817336.com | www.11044.cc | www.7406.Com | www.ejylc17.com | www.659618.com | www.607967.com | www.s | www.282456.com | www.v30226.com | www.shenbobet.com | 37570a.com | 26119.com | pj00kk.com | 3678yy.com | 22115003.com | 7347999.com | x7267.com | hg993.cc | df6272.com | js345345.com | 5651r.com | www.77114v.com | www.177741.com | www.481770.com | www.695093.com | www.876488.com | www.901257.com | www.838669.com | www.921977.com | www.179012.com | www.952583.com | www.c6712.com | www.flff7.com | www.df94.com | www.819847.com | www.863012.com | www.743966.com | www.635852.com | www.560103.com | www.424221.com | www.576126.com | www.506273.com | www.390500.com | www.330291.com | www.030310.com | 68680029.com | 20773311.com | 66000.com | hd81366.com | 3404d.cc | 3467y.cc | zunyi801.com | 50000944.com | www.7720l.com | www.09569c.com | www.93480.com | www.yt7488.com | www.77c668.com | www.xin888111.com | d1915.com | jk080.com | csc998.com | 3434mmm.com | 5005u.com | www.b3654.com | www.c27229.com | www.hg2516.com | www.38238d.com | www.b35ss.com | www.xpj916.com | www.ejylc15.com | www.71399g.com | www.66ffj.com | www.554363.com | www.055976.com | 99306n.com | 2864y.com | xpj212.com | 8522rrrr.com | 1389a.com | www.090040.com | www.55717u.com | www.50732m.com | www.936271.com | www.156020.com | 44488i.com | 1408z.com | q8q9.com | www.rbet3365.com | www.hg3326.com | www.88166v.com | www.288021.com | www.8839m.com | www.582006.com | mgm01.net | 1483g.com | 0186556.com | 5030.com | www.mt2888.com | www.03bet8.com | www.868229.com | www.c131.vip | zhcp72.com | shen5522.com | 3121.com | www.028448.com | www.9737kk.com | 9694o.com | 85698x.com | www.wnsr800.com | www.700hm.com | www.69567o.com | www.14412.com | www.055123.cc | 588ppp.cc | 91019t.com | www.4938p.com | www.4212e.com | www.xb88.com | www.196046.com | rrr5682.com | 2jszzz.com | www.bwin299.com | www.229sunbet.com | www.42070012.com | www.920959.com | 3508666.com | 22098.com | www.vns9998.com | www.911137.com | www.0134008.com | www.598966.com | 55818.com | 00jj8331.com | www.k2229k.com | www.99552zz.com | www.949498.com | 3122ff.com | 5437k.com | www.9374y.com | www.hdcp886.com | www.90305d.com | df8t.com | 1104006.com | www.42424688.com | www.04567m.com | www.87668p.com | 35ll.vip | 66671j.com | www.900652.com | www.a88.com | www.985576.com | 3258r.com | x333.co | www.xpj00220.com | www.6678695.com | www.177804.com | 54249955.com | www.88807b.com | www.9895s.com | www.803875.com | aa67890.com | www.814suncity.com | www.g3065.com | www.1333ac.com | feicai0878.com | 168cp-x.com | www.9478.com | www.lczg1.com | 4066zz.com | 8884048.com | www.00772h.com | www.943893.com | 80878o.com | www.7720p.com | www.7225g.com | www.834918.com | 856789.com | www.56520z.com | www.361148.com | www.093388.com | 822051.com | www.41610.com | www.68682k.com | 5478h.com | bcylc55.com | www.1112737.com | www.611669.com | 55967t.com | www.9679e.com | www.53900n.com | 496dd.com | www.qian00.com | www.lhg5555.com | www.178571.com | 33vv8331.com | www.d526688.com | www.998349.com | 5622w.com | www.hg888995.com | www.36166h.com | 1592o.com | www.8694a.com | www.xh289.com | qijidianyou.com | www.81866c.com | www.js89i.vip | 44446.com | 3167.com | www.0600p.cc | 2851l.com | www.86611r.com | www.7036g.com | ctxcp76.com | long677.com | www.60886a.com | 5001s.com | t365e.com | www.835991.com | 3844t.com | www.89422.com | www.390737.com | bg7666.com | www.c22365.com | www.3978o.com | 008423.com | www.k84551.com | www.33598f.com | xpjggzz.com | www.111153.com | www.912484.com | 655ib.com | www.9737vv.com | www.033826.com | 1484vip2.com | www.456669.com | hg7033.org | www.xh6666.com | www.715613.com | 009900h.com | www.79095l.com | bb888877.com | www.benz4343.com | www.7782g.com | r01234.com | www.8860tt.com | vipvip0000.com | www.ag9811.com | www.80767h.com | 66300vip25.com | www.a456x.com | www.50024i.com | www.hg6969.net | www.50064k.com | p8159.cc | www.93955.com | 3049w.com | www.572433.com | www.bxcp66.com | 3136yy.com | www.5956868.com | 9646l.com | www.38345p.com | 4195cc.com | www.wns8833.com | www.845755.com | 6830ff.com | www.162323.com | 0004116.com | www.bwinyz28.com | dzjgw7777.com | www.212323.com | www.50989i.com | www.9478u.com | 249163.com | www.83008f.com | www.456836.com | www.pj5902.com | www.18005.com | 4809u.com | www.xb88.com | 6363xx.com | www.yl61332.com | 8901.com | www.7893.ag | 8722.com | www.3157c.com | 3mgmvvv.com | www.105546.com | 9645ll.com | www.vns77999.com | w69441144.com | www.hg8968.com | www.326366.com | www.9996vv.com | www.528112.com | www.v3304.com | www.652918.com | www.pjzhejiang.com | www.934277.com | www.65533d.com | www.959553.com | www.e26055.vip | www.lczg4.com | www.68666l.com | www.cf9905.com | www.hg2566.net | www.731091.com | www.621155c.com | www.766602.com | www.727xpj.com | yabo1188.com | www.2418t.com | 33318u.com | www.0270j.com | 1077ggg.com | www.cs505.com | www.303473.com | www.js5666.com | 4880l.com | www.03345.com | 01234ggg.com | www.4727.com | 4912d.com | www.cc4625.com | 80850s.com | www.61233d.com | 5446yy.com | www.786819.com | www.2211sb.com | 99589j.net | www.hg039.com | uuu5144.com | www.938j.cc | 1234567cai.com | www.535666.com | 3779955.com | www.g94600.com | b5429.com | www.rrle7.com | www.558422.com | v61653.com | www.l456x.com | 019dh.com | www.679950.com | k2554.com | www.799427.com | www.272875.com | xin666bb.com | www.cn365t.com | 3568uu.com | www.8816s.com | www.hg2729.com | 32126h.net | www.551c93.com | 4036yy.com | www.61655s.com | www.999ldz.com | dx888.com | www.854608.com | 0471sands.com | www.99383.com | www.7hg88.com | 563452.com | www.sb5507.com | 6363ii.com | www.w796.com | www.9988619.com | 1106.com | www.16065k.com | www.ylg5999.com | 22966.com | www.5099xx.com | 9101906.com | www.926887.com | www.hg93777.com | 3157777.com | www.ya2019c.com | www.753055.com | 1624aa.com | www.8905k.com | 3225c.com | www.072211.com | www.7415hh.com | xpj65.com | www.517075.com | www.3126w.com | www.k84551.com | 4812h.com | www.550021j.com | www.00829d.com | 11989y.com | www.36587777.com | www.h7788r.com | 150055.com | www.707213.com | 3009b.com | www.126509.com | www.8967i.com | dzc08.com | www.499428.com | www.19019c.com | 175070.com | www.43131h.com | www.4521t.com | 88052.com | cn.man853.com | www.7886263.com | www.hg2328.com | 73055s.com | www.61233p.com | www.js8040.com | dzj17.com | www.hy5504.com | www.lfcp095.com | ib738.com | www.160881.com | www.yh234a.com | www.68666b.com | 1591003.com | www.998855k.com | www.143vns.com | 88ee940.com | www.21202ii.com | www.jz928.com | 588fff.cc | xsj.com | www.91junzi.com | www.58767.com | 3435r.com | www.209875.com | www.v1058.com | www.benz4400s.com | so1111.cc | www.918ar.com | www.938g.cc | 883399x.com | 4123ii.com | 5509u.com | www.45598t.com | dz883.com | 55445156.com | www.81678w.com | www.643sunbet.com | 77882007.com | 588hhh.cc | www.84499k.com | www.888ding.com | 55188.com | fff3405.com | www.5522s.cc | www.518737.com | 9994001.com | 66458y.com | www.723095.com | www.40339.com | www.330099s.com | 01234mm.com | tt6831.com | www.50989f.com | www.20199mm.com | 1665f.com | 79964t.com | www.874110.com | www.455361.com | www.d0686.com | cp088z.com | www.393890.com | www.tai1177.com | www.12345699.com | 3258z.com | 2019kk.cc | www.550134.com | www.444999qipai.com | www.pj5633.com | feicai0917.com | 20773388.com | www.506477.com | www.7004k.com | www.009789.com | 88535u.com | 0615009.com | 888.SK | www.6364x.com | www.bwinyz15.com | www.25288h.com | 780.so | hd9909.com | www.355183.com | www.bet73w.com | www.551c93.com | www.75878tt.com | ib738.com | 0270098.com | www.526197.com | www.hh03035.com | www.5049e.com | www.333222w.com | 3552r.com | 3122e.com | www.5095p.com | www.xpj16683.com | www.3311sb.com | x33n.vip | 1168x.com | www.840680.com | www.5446n.com | www.66ffi.com | www.amxj8855.com | 55ee8332.com | 2844s.com | 80850c.com | www.hczx2.com | www.56011q.com | www.5f33.com | www.h067.com | 80850ii.com | 6002x.com | feicai.cc | www.960121.com | www.99997148.com | www.19019u.com | www.330099r.com | 88894t.com | 35222oo.com | 444144.com | www.65707a.com | www.2350u.com | www.hg36799.com | www.98698i.com | www.slr000.com | www.lhg555.com | 9988xpj.com | f465.com | 068.cc | www.196095.com | www.66ffi.com | www.35898a.com | www.04567e.com | www.7669mm.com | www.995z.net | hrviip1.com | 88772007.com | 8040hhh.com | vv56988.com | www.407870.com | www.33997c.com | www.555999qipai.com | www.71071b.com | www.34656.com | www.u30226.com | ylyrm.com | 2757000.com | 31553a.com | 4694q.com | 168cp-r.com | www.306503.com | www.c757.vip | www.39500f.com | www.55717r.com | www.4828778.com | www.85857x.com | www.344559.com | www.792suncity.com | 748v.com | www.b8cp.com | www.yhxizang.vip | www.www-66000.com | 6977555.com | 8449ii.com | 991381.com | 4255uuu.com | 655660088.com | 53694567.com | stsvip9.com | 2595u.com | www.29277a.com | www.399957.com | www.867865.com | www.c134.vip | www.0014o.com | www.53900m.com | www.2418u.com | www.1764y.com | www.774546.com | www.9737qq.me | www.258suncity.com | www.76775c.com | www.hg8041.com | www.ra1116.com | www.77537w.com | www.69229.com | www.28758q.com | www.0555hg.com | www.517ly13.com | 1589vip.com | feicai0712.com | 50000027.com | 66876z.com | 20188n.com | 55cc8332.com | 8827a.com | 78117799.com | 5429u.com | www.5550105.com | www.6667727.com | www.3435333.com | www.6033m.com | www.sjs07.com | www.kim111.com | www.7435v.com | www.353599.com | www.yh1666.com | www.7435b.com | www.hg66668.cc | www.yh6679.com | www.09527a.com | www.hg93499.com | www.k87087.com | www.6372008.com | www.115385.com | www.js353535.com | www.?28558.com | www.8bet005.com | www.b35jj.com | www.06820f.com | www.80080.com | www.42456699.com | www.1855ff.com | www.89911.cc | www.hjin6.com | www.755914.com | www.347977.com | wns2.net | 7935n.com | 7508l.com | i45638.com | 4255.com | 876023.com | 87665n.com | www.ven4444.com | www.09569p.com | www.99857.com | www.c1724.com | www.http://09991.com | www.1779.com? | www.ww.68203e.com | www.6364b.com | www.911750.com | www.183096.com | 683bet.com | 3778dd.com | q3405.com | feicai0414.com | www.agg8887.com | www.87680c.com | www.zz00y.com | www.99113q.com | www.js89u.vip | www.c17848.com | www.qm72.com | www.209882.com | 17yy.com | 9995bcc | 3467l.am | 99066555.com | www.599suncity.com | www.174886.com | www.6880ll.com | www.77537.com | www.8fk.com | www.068619.com | 1463j.com | 66671c.com | 33552229.com | www.wnsr858.com | www.129u.com | www.4996jx.com | www.89888.com | www.cp8009.cc | 08530002.com | 238228.com | x33a.vip | www.333222n.com | www.zfzx365.com | www.06386666.com | www.80075y.com | www.603224.com | 518cp-7.com | 33318k.com | feicai0745.com | www.792suncity.com | www.w948w.com | www.96756.com | www.960206.com | 11betbet365.com | 69440055.com | w0595.com | www.hg9166.com | www.w84s.com | www.2109g.com | MM98.top | 9994net0.com | 9420k.com | www.tk533.com | www.280sun.com | www.sxyl7.com | 923.com | 5906mm.com | 3544b.com | www.553525.com | www.hgdc200.com | www.3478e.cc | p979.com | g40033.com | www.147755.com | www.lxyl360.com | www.rrqp777.com | www.629683.com | zhcp47.com | 22299bb.com | www.xpj5t5.com | www.3066kk.com | www.6364b.com | qg162.com | a3405.com | www.p27229.com | www.848777q.com | www.3126t.com | 87665r.com | 58582325.com | www.88807x.com | www.256531.com | www.gai06.com | 1775y.com | 61323366.com | www.3844d.com | www.780780b.com | www.500231.com | 40661114.com | 7335q.com | www.a11133.com | www.12455hh.com | www.55885o.com | 4288d.com | www.csjindan.com | www.06386677.com | www.605999aa.com | 603144.COM | 1592x.com | www.9b004.com | www.hg82678.com | www.541522.com | 47727.net | www.223456g.com | www.06820p.com | www.861150.com | 1407y.com | www.7435d.com | www.sha2299.com | www.cp8006.cc | 55qq8331.com | www.n32126.cc | www.30350k.com | www.655101.com | sjg008.com | www.22xpjdc.com | www.63606l.com | www.383897.com | 4025l.com | www.wns02222.com | www.w63568.com | 3339964.com | 8977tt.com | www.400131.com | www.50064p.com | ylg2566.com | www.k80282.com | www.06820n.com | www.580896.com | 36401177.com | www.888vip7.com | www.860505.com | www.qmfc7.com | www.073552.com | 00zz8331.com | www.03808.com | www.51331f.com | 9679s.com | www.8181sun.com | www.cn365e.com | www.444087.com | y67890.com | www.3814222.com | www.00840b.com | aa00558.com | www.pj9898.com | www.63606v.com | cc32355.com | 55331ll.com | www.527576.com | www.w796.com | 6175hh.com | www.25msc.com | www.41518m.com | 80368xx.com | www.2078e.com | www.68689m.com | hg10n.com | www.zzzz0265.com | www.4988b.cc | 8520f.com | www.hg009999.com | www.001170.com | f7454.com | www.719365.com | www.1007.cc | 1389bb.com | www.zsdl9.com | www.36166d.com | vv00558.com | www.9816666.com | www.9149i.com | 3y5511.com | www.110048.com | www.992358.com | 655661100.com | www.mhcp4.com | www.378016.com | bwin8h.com | www.4058hh.com | 3049m.com | www.709899.com | www.983258.com | c63awgd8.com | www.279765.com | www.918io.com | 3807z.com | www.169009.com | www.302210.com | 5804l.com | www.hr1822.com | 1624cc.com | www.9785333.com | www.2222y.cc | 908080d.com | www.9737aa.com | hg88814.com | www.6cw.org | www.sx139973.com | 08778t.com | www.drf0432.com | www.514918.com | 6868ll.cc | www.55717h.com | 5647p.com | www.0333444.com | www.655096.com | 081753.com | www.ax630.com | 00ff8332.com | www.005mgm.com | www.282990.com | www.ylg343.com | www.799941.com | 1813g.com | www.4963ll.com | 30007d.com | www.58777p.com | www.47370.cc | dwyl007.com | www.44118p.com | 3844oo.com | www.166tk.com | www.317787.com | 1594005.com | www.33588h.com | 316m.cc | www.99552vv.com | 4018tt.com | www.388msc.com | 1422b.com | www.91990a.com | www.808913.com | 20772244.com | www.26878f.com | pj9937.com |